1 Answers
Code:
#include <iostream>
using namespace std;
class stud
{
private:
int id;
char name[20];
public:
void getstud()
{
cout<<“Enter the student id and student name:\n”;
cin>>id>>name;
}
void putstud()
{
cout<<“Id :”<<id<<endl;
cout<<“Name :”<<name<<endl;
}
};
class physical : public stud //public derivation
{
float ht, wt;
public:
void getph()
{
cout<<“Enter the student height and weight: \n”;
cin>>ht>>wt;
}
void putph()
{
cout<<“Height :”<<ht<<endl;
cout<<“Weight :”<<wt<<endl;
}
};
int main()
{
physical ph;
ph.getstud();
ph.getph();
ph.putstud();
ph.putph();
return 0;
}
Output:
Enter the student id and student name:
420
ChetanShidling
Enter the student height and weight:
7
80
Id:420
Name: ChetanShidling
Height:7
Weight:80