Program //Example of Inheritance #include #include class person { char name[20]; int age; public: void read_data(); void display_data(); }; void person :: read_data() { cout<<"\nEnter the details for class person\n\nEnter Name: "; cin>>name; cout<<"Enter Age: "; cin>>age; } void person :: display_data() { cout<<"\n\nName: "<>roll; cout<<"Enter Marks: "; cin>>marks; grade=compute_grade(); } char student :: compute_grade() { char gd; if (marks<200) gd='D'; else if (marks<240) gd='C'; else gd='A'; return gd; } void student :: show_data() { cout<<"\nRoll No: "<
void main() { clrscr(); student obj; //create an object of student type cout<<"\t\t\tPerson -> Student"; cout<<"\nClass 'student' inherits form class 'person'\n\n"; obj.get_data(); //read data of a student cout<<"\n\nDetails of the student using the object of the class 'student': "; obj.display_data(); //inherit function from class person obj.show_data(); getch(); }