class DerivedClass:access_specifier base_class{ };
class Car:public Vehicle{ };
class Car:public Vehicle
class Car:protected Vehicle
class Car:private Vehicle
class Car: Vehicle
Access Mechanism in Classes
Effects of Inheritance on Members Visibility
Member Access in Base Class
private | protected | public |
---|---|---|
Always inaccessible regardless of derivation access |
Private in derived class if you use private derivation |
Private in derived class if you use private derivation |
Protected in derived class if you use protected derivation |
Protected in derived class if you use protected derivation |
|
Protected in derived class if you use public derivation |
Public in derived class if you use public derivation |