| | | | | |

Inheritance of Member Variables

  • Class Variables and Method Prototypes are inherited
  • Variables of the base class also exist in the derived class
  • When inheritance is public or protected then any public variable in the base class can be accessed directly by derived class objects
  • Private variables of the base class can not be accessed directly by the derived class
  • Often indirect access is enough:
  • Cube::Cube(float side) : Box(side, side, side)
    {}
    
  • Private base class data is also accessed by the inherited method Volume()

| | Top of Page | 9. C++ Classes Part 3: Inheritance - 7 of 16