C++ Single Level Inheritance Example: Inheriting Methods

  c++

Email

#include<iostream>

using namespace std;

class Anil{

public :

void setname()
{
cout << “teing coding”;
}

};

class Book : public Anil{

public :

void setdate()
{
cout << “this codng theibe”;
}

};

int main()
{

Book naik;
naik.setname();
naik.setdate();
}

Spread the Code

Leave a Reply

avatar

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

  Subscribe  
Notify of