Search code examples
c++inheritanceprivatepublic

C++ inheritance public and private?


Is it possible to inherit both or all parts of a class (other than private) in C++?

class A {
}


clas B : ...? { }

Solution

  • If you're asking whether you can make private members visible to derived classes, the answer is no - that's why they are private. Use protected members in the base class if you want derived classes to be able to access them.