Compiler Error C2248

'member' : cannot access 'access' 'member' declared in class 'class'

The specified private or protected member of a class, structure, or union was accessed.

Tips

This error can be caused by attempting to access a member that is declared as private or protected, or by accessing a public member of a base class that is inherited with private or protected access. The member should be accessed through a member function with public access or should be declared with public access. The following is an example of this error:

class X
{
public:
   int  m_pubMemb;
   void setPrivMemb( int i ) { m_privMemb = i; }
protected:
   int  m_protMemb;
private:
   int  m_privMemb;
} x;

class Y : X {} y;    // default access to X is private

void main()
{
   x.m_pubMemb;      // OK, m_pubMemb is public
   x.setPrivMemb( 0 ); // OK, uses public access function
   x.m_protMemb;     // error, m_protMemb is protected
   x.m_privMemb;     // error, m_privMemb is private
   y.m_pubMemb;      // error, Y inherits X as private
   y.setPrivMemb( 0 ); // error, Y inherits X as private
}