When be creating a new class from a existing class is called inheritance. existing class is callesd Base class.base class is also knows as Parent class.or A new class is was creating is called Derived class.this class is also knows as child class.
Type of Inheritance.
#include< iostream> using namespace std; class Person { int id; char name[100]; public: void set_p() { cout<<"Enter Id:"; cin>>id; fflush(stdin); cout<<"Enter Name:"; cin.get(name,100); } void display_p() { cout<< endl<< id<<"\t"<< name<<"\t"; } }; class Student: private Person { char course[50]; int fee; public: void set_s() { set_p(); cout<<"Enter Course Name:"; fflush(stdin); cin.getline(course,50); cout<<"Enter Course Fee:"; cin>>fee; } void display_s() { display_p(); cout<< course<<"\t"<< fee<< endl; } }; main() { Student s; s.set_s(); s.display_s(); return 0; }