Advertisement
steverobinson

Steve Robinson

Aug 18th, 2010
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. //Public Inheritance
  2. #include <iostream.h>
  3. #include <conio.h>
  4.  
  5. class student
  6. {
  7.     int roll,avg;
  8.     char address[10],name[10];
  9.     public:
  10.         void get_info()
  11.         {
  12.             cout<<"\nPlease Enter the Name of the student:...";
  13.             cin>>name;
  14.             cout<<"Enter Roll No. of "<<name<<" :...";
  15.             cin>>roll;
  16.             cout<<"Enter Address  of "<<name<<" :...";
  17.             cin>>address;
  18.             cout<<"Enter Average Mark of "<<name<<" :...";
  19.             cin>>avg;
  20.            
  21.         }
  22.         void display()
  23.         {
  24.             cout<<"\nRoll No: "<<roll<<"\nName: "<<name<<"\nAddress: "<<address;
  25.             cout<<"\nAverage Mark: "<<avg;
  26.         }
  27.  
  28. };
  29. class fitness:public student
  30. {
  31.     float weight, height;
  32.     public:
  33.         void get_fit()
  34.         {
  35.             cout<<"Enter Height :...";
  36.             cin>>height;
  37.             cout<<"Enter Weight of :...";
  38.             cin>>weight;
  39.         }
  40.         void print_fit()
  41.         {
  42.             cout<<"\nHeight: "<<height<<"\nWeight: "<<weight;
  43.         }
  44. };
  45. int main()
  46. {
  47.     clrscr();
  48.     fitness stu1;
  49.     cout<<"\nEnter the Student Details:\n-----------------------------------\n";
  50.     stu1.get_info();
  51.     stu1.get_fit();
  52.     cout<<"\n\nThe give Student Details are:\n--------------------------------\n";
  53.     stu1.display();
  54.     stu1.print_fit();
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement