Reputation: 195
I am currently using the old VC++98, and I am facing issues trying to encapsulate a static member declared as private in a base class. I wish that the derived classes do not have access to such static member, but I can't find out how. The following example code is compiling and running without problems (whereas it should not, in my opinion):
class Base
{
private:
static int integer;
};
int Base::integer=0; //initialization
class Derived : public Base
{
public:
int GetInteger(){return Base::integer;}
};
How can I make the static member inacessible in the derived class?
Upvotes: 0
Views: 75
Reputation: 75924
How can I make the static member inaccessible in the derived class?
Use a compliant compiler. The code doesn't compile in standard C++ (any version) just like you expect.
Upvotes: 1