previous | start | next

1.2.2 Accessing base class data in the derived class.

The Manager class inherits both the public and private sections of the Employee class, but can only access them through the public interface.



double Manager::getBonus() const
{
 return 2 * salary;   // ERROR. salary is private in Employee
}



double Manager::getBonus() const
{
 return 2 * getSalary();   // getSalary is public in Employee
}



previous | start | next