I haven't done C++ in a while and can't figure out why following doesn't work:
class A {
protected:
int num;
};
class B : public A {
};
main () {
B * bclass = new B ();
bclass->num = 1;
}
Compiling this produces:
error C2248: 'A::num' : cannot access protected member declared in class 'A'
Shouldn't protected members be accessible by derived classes?
What am I missing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…