D
Daniel Aarno
Can anyone provide a good explanation to why the following does not
work? After all since A is a public base of B objects of type B ISA
object of type A.
class A {
protected:
void foo() {}
};
class B : public A {
public:
void bar(A &a, B &b) {
foo(); //< OK, accessing A::foo in *this
b.foo(); //< OK, accessing A::foo in other object of type B
a.foo(); //< ERROR: foo() is protected in this context
}
}
/Daniel
work? After all since A is a public base of B objects of type B ISA
object of type A.
class A {
protected:
void foo() {}
};
class B : public A {
public:
void bar(A &a, B &b) {
foo(); //< OK, accessing A::foo in *this
b.foo(); //< OK, accessing A::foo in other object of type B
a.foo(); //< ERROR: foo() is protected in this context
}
}
/Daniel