single level inheritance (derived class) : private (base class)
Mon Oct 02 2023 03:54:13 GMT+0000 (Coordinated Universal Time)
Saved by
@rahulk
#include <iostream>
using namespace std;
class stu
{
int id;
char name[10];
public:
void get_data()
{
cout<<"enter student name:";
cin>>name;
cout<<"enter student id:";
cin>>id;
}
void put_data()
{
cout<<"name="<<name;
cout<<"id="<<id;
}
};
class phy:private stu
{
int w ,h;
public:
void get_phy()
{
get_data();
cout<<"enter student height:";
cin>>h;
cout<<"enter student weight:";
cin>>w;
}
void put_phy()
{
put_data();
cout<<"height="<<h;
cout<<"weight="<<w;
}
};
int main()
{
phy p;
p.get_phy();
p.put_phy();
cout<<"hello";
return 0;
}
content_copyCOPY
Comments