R
Roka
Hi all
why cann't I access protected var from a inherited class?
Code example:
class Base{
protected:
int color;
public:
virtual void show() = 0;
};
class Testublic Base{
public:
Test(int c = 1):color(c){ }; //WHY COMPILE ERROR ??
void show(){
cout << color << endl; // WHY THIS IS OK ??
}
};
int main(void){
Test* test = new Test(10);
test->show();
return 0;
}
THANKS;
why cann't I access protected var from a inherited class?
Code example:
class Base{
protected:
int color;
public:
virtual void show() = 0;
};
class Testublic Base{
public:
Test(int c = 1):color(c){ }; //WHY COMPILE ERROR ??
void show(){
cout << color << endl; // WHY THIS IS OK ??
}
};
int main(void){
Test* test = new Test(10);
test->show();
return 0;
}
THANKS;