You use a using statement to alter the specific symbols access level, like this
-
class base
-
{
-
public:
-
int a;
-
int b;
-
int c;
-
int d;
-
};
-
-
class derived : public base
-
{
-
private:
-
using base::a;
-
};
-
However it should be noted that best practice is for all class data to be private (or at least protected) and to provide getters and setters for them. You could do this just by using private inheritance and providing the getters and setters in the derived class.
-
class derived : private base
-
{
-
public:
-
int getA(){ return a; };
-
int getB(){ return b; };
-
int getC(){ return c; };
-
int getD(){ return d; };
-
-
void setA(int value){ a = value; };
-
void setB(int value){ b = value; };
-
void setC(int value){ c = value; };
-
void setD(int value){ d = value; };
-
};
-