If the member variable of the base class is protected or public, you can simply reference it by name in any member function of the derived class. If it is private to the base class, the compiler will not allow the derived class to access it at all. Example:
class Base
{
protected:
int a;
private:
int b;
};
class Derived : public Base
{
void foo()
{
a = 5;
b = 10;
}
};
, - .
, "" :
class Base
{
public:
int a;
};
class Derived : public Base
{
public:
int a;
};
a: Base, Derived, , , .