I want to know if I can split a C++ class declaration
Original class
class P
{
private:
int id;
//some really
You can heritage the second part like this:
//Class P_Hetitage definition
class P_Heritage {
protected:
int id;
//some really secret method
int secretMethod();
}
//Class P definition
class P : private P_Heritage {
protected:
int x;
public:
P();
int getX();
};
Below a straightforward explanation how inheritance works:
Inheritance the class P_Heritage as:
public
- public elements are public to class P
- protected elements are private to class P
private
- public elements are private to class P
- protected elements are private to class P
P_Heritage's private elements can not be seen by class P