Private Inheritance in C++ | Cpp

  c++

Email

#include<iostream>

using namespace std;

class Anil{
protected:

string name;

public :

void stename(string iname)
{
name = iname;
}
};
class Book : private Anil{
public :

void display()
{
cout << name;

}

void bookname(string iname)
{
stename(iname);
}

};

class Gsstud : public Book{
public :

void displuw(string iname)
{
bookname(iname);
}

};

int main()
{
Gsstud naik;
naik.displuw(“stomg “);
naik.display();
return 0;

}

Spread the Code

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of