class Sub_Class : public Super_Class
{
}
From based(super, parent) class to derived(sub, child) class
class A;
class B : public A;
int main()
{
A objA;
B objB;
A* q = &objB
}
A parent’s pointer can point to it’s child, but it cannot access the member that only in B
UPerson is the parent, student is the child
Perfect match of function argument will be more prefered
class person;
class student: public person;
class PG: public student;
int main()
{
A objA;
B objB;
A* q = &objB
}
PG is the indirect derived class of person
person is the indirect base class
Derived class should use MIL to initialize the base class
C++ will add the default constructor of base class to MIL
If there are no default constructor, compile error
Slicing:
If we copy a derived class to base, the object will be sliced