Thursday, August 18, 2022

TYPES OF INHERITANCE

 #include<iostream>

using namespace std;

class Parent

{

private: int a;

protected: int b;

public: int c;


 void funParent()

 {

 a=10;

 b=5;

 c=15;

 }

};

class Child: private Parent

{

private:


protected:


public:


 void funChild()

 {

 //a=10;

 b=5;

 c=15;

 }

};

class GrandChild : public Child

{

public:

 void funGrandChild()

 {

 //a=10;

 //b=5;

 //c=20;

 }

};

int main()

{

 // Child c;

 //c.a=10;

 //c.b=5;

 //c.c=20;

}

No comments:

Post a Comment

CONSTRUCTURE IN PARENT CLASS

class Parent {     public Parent()     {         System.out.println("Parent Constrcutor");     }              } class Child extend...