Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Public Inheritance
- #include <iostream.h>
- #include <conio.h>
- class student
- {
- int roll,avg;
- char address[10],name[10];
- public:
- void get_info()
- {
- cout<<"\nPlease Enter the Name of the student:...";
- cin>>name;
- cout<<"Enter Roll No. of "<<name<<" :...";
- cin>>roll;
- cout<<"Enter Address of "<<name<<" :...";
- cin>>address;
- cout<<"Enter Average Mark of "<<name<<" :...";
- cin>>avg;
- }
- void display()
- {
- cout<<"\nRoll No: "<<roll<<"\nName: "<<name<<"\nAddress: "<<address;
- cout<<"\nAverage Mark: "<<avg;
- }
- };
- class fitness:public student
- {
- float weight, height;
- public:
- void get_fit()
- {
- cout<<"Enter Height :...";
- cin>>height;
- cout<<"Enter Weight of :...";
- cin>>weight;
- }
- void print_fit()
- {
- cout<<"\nHeight: "<<height<<"\nWeight: "<<weight;
- }
- };
- int main()
- {
- clrscr();
- fitness stu1;
- cout<<"\nEnter the Student Details:\n-----------------------------------\n";
- stu1.get_info();
- stu1.get_fit();
- cout<<"\n\nThe give Student Details are:\n--------------------------------\n";
- stu1.display();
- stu1.print_fit();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement