Sunday, 3 April 2016

Private , Public & Protected Modes In Inheritance

Private:

The private members of a base class can only be accessed by members of that base class .

Public:

The public members of a base class can be accessed by members of that base class, members of its derived class as well as the members which are outside the base class and derived class.

Protected:

The protected members of a base class can be accessed by members of base class as well as members of its derived class.

In short:

private: base
protected: base + derived
public: base + derived + any other member

No comments:

Post a Comment