
















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















class Child1:public Parent
...
class GrandParent{}; class Parent1: public GrandParent {}; class Child1:public Parent1{};
class GrandParent{
int gpData;
public:
GrandParent() : gpData(0){...} GrandParent(int i) : gpData(i){...} void Print() const;
};
class Parent1: public GrandParent{
int pData;
public:
Parent1() : GrandParent(), pData(0) {…}
};
GrandParent Print()
Parent
Child Print()
int main(){
Child1 obj; obj.Print(); obj.Parent1::Print(); obj.GrandParent::Print(); return 0;
}
Child1::Print
GrandParent::Print
GrandParent::Print
Base Class Derived Class
Public Public
Protected Protected
Private Hidden
class Child: public Parent {…};
Base Class Derived Class
Public Protected
Protected Protected
Private Hidden
class Child: protected Parent {…};
class Child: private Parent {…}
is equivalent to
class Child: Parent {…}