02 Program

  • Uploaded by: Class 12 A
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View 02 Program as PDF for free.

More details

  • Words: 170
  • Pages: 2
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(); }

Related Documents

02 Program
November 2019 20
02 Program Pertama
April 2020 30
Program
May 2020 25
Program
October 2019 41
Program
June 2020 15
Program
July 2020 18

More Documents from ""

08 Output
November 2019 18
02 Program
November 2019 20
05 Program
November 2019 14
01 Program
November 2019 15
04 Program
November 2019 19
03 Program
November 2019 8