|
|
Le 27/11/2010 15:00, clipka nous fit lire :
> Hacking happily along at the POV-Ray code, I stumbled across this MS
> Visual Studio 2005 C++ anomaly:
>
> class A
> {
> protected:
> void a() {}
> };
>
> class B : public A
> {
> protected:
> void b(A* other)
> {
> this->a(); // (1)
> other->a(); // (2)
> }
> };
>
> While (1) compiles fine, (2) raises an error C2248, "'A::a' : cannot
> access protected member declared in class 'A'"
>
> What the F*** am I doing wrong here?
Issue of C++, or on the chair ?
(1) is ok because B is an A, so can access the protected function.
(2) is not allowed because a() of A is protected, so can only be called
by the object itself (in a gross simplification).
Works as designed.
Post a reply to this message
|
|