'member' : cannot access access member declared in class 'class'
Members of a derived class cannot access private members of a base class. Objects created from a class cannot access protected or private members of that class.
See Knowledge Base article Q243351 for more information on C2248.
The following sample generates C2248:
#include <stdio.h> class X { public: int m_pubMemb; void setPrivMemb( int i ) { m_privMemb = i; printf("\n%d", m_privMemb); } protected: int m_protMemb; private: int m_privMemb; } x; void main() { x.m_pubMemb = 4; printf("\n%d", x.m_pubMemb); x.setPrivMemb(0); // OK, uses public access function x.m_protMemb = 2; // error, m_protMemb is protected x.m_privMemb = 3; // error, m_privMemb is private }
You may also see this error when using Managed Extensions for C++:
#using <mscorlib.dll> __gc class Base { protected: void Method() { Console::WriteLine("protected"); } }; __gc class Der : public Base { void Method() { ((Base*)this)->Method(); // C2248 // try ... // Base::Method(); } }; void main() { }