"is protected within this context" error
From: H. S. (g_reate_xcalibur_at_yahoo.com)
Date: 03/24/05
- Next message: Victor Bazarov: "Re: "is protected within this context" error"
- Previous message: Georg Bauhaus: "Re: Teaching new tricks to an old dog (C++ -->Ada)"
- Next in thread: Victor Bazarov: "Re: "is protected within this context" error"
- Reply: Victor Bazarov: "Re: "is protected within this context" error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 23 Mar 2005 23:08:16 -0500
I am getting this error if I try to compile the file demarcated below.
What I am missing here? I am using g++ (GCC) 3.3.5 (Debian 1:3.3.5-8).
{tp2}> g++ -ansi -g -Wall tp2.cc -o tp2
tp2.cc: In member function `void Other::DoSomething()':
tp2.cc:11: error: `int Base::iX' is protected
tp2.cc:29: error: within this context
// %< %< ----------------------------------- %< %<
#include <cstdio>
#include <iostream>
class Base{
public:
Base();
protected:
int iX;
};
Base::Base():iX(7){}
class Derived:public Base{};
class Other{
public:
Derived* D;
void DoSomething();
};
void Other::DoSomething(){
std::cout << D->iX;
}
int main(){}
// %< %< ----------------------------------- %< %<
Thanks,
->HS
-- Please remove the underscores ( the '_' symbols) from my email address to obtain the correct one. Apologies, but the fudging is to remove spam.
- Next message: Victor Bazarov: "Re: "is protected within this context" error"
- Previous message: Georg Bauhaus: "Re: Teaching new tricks to an old dog (C++ -->Ada)"
- Next in thread: Victor Bazarov: "Re: "is protected within this context" error"
- Reply: Victor Bazarov: "Re: "is protected within this context" error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|