"is protected within this context" error

From: H. S. (g_reate_xcalibur_at_yahoo.com)
Date: 03/24/05


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.


Relevant Pages

  • Re: calling a function in cpp
    ... You've placed what should be class data members in the member function ... int seconds1, seconds2, hours, minutes, seconds; ... > void substraction(); ...
    (comp.lang.cpp)
  • Trying to learn dynamic binding...
    ... void func(){ ... class der: public base{ ... int main{ ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Easy Question - LINK2005 error
    ... int number; ... void SetNumber; ... by the merest coincidence had the same name as a member function of a class, ... declared in a .cpp file that was NOT included in some other compilation by doing #include. ...
    (microsoft.public.vc.mfc)
  • Re: default parameter value
    ... > void f(int a, int b) ... if the above is a member function of a class and the 'default argument' ... is some class member. ...
    (comp.lang.cpp)
  • Re: The c++ way?
    ... > int Get; ... > void Get ... you are using an actual member function to get the data. ... The cast operator would be defined as so: ...
    (comp.lang.cpp)