#include<iostream.h>
#include<conio.h>
class student
{
char name[20];
int roll;
public:
void input()
{
cout<<"Enter Name";
cin>>name;
cout<<"Enter Roll No.";
cin>>roll;
}
void display()
{
cout<<"Student details";
cout<<"Name:"<<name;
cout<<"\nRoll No."<<roll;
}
};
class subject:private student
{
char sub[20];
public:
void input()
{
student::input();
cout<<"Enter subject";
cin>>sub;
}
void display()
{
student::display();
cout<<"\nSubject"<<sub;
}
};
void main()
{
subject ob;
ob.input();
ob.display();
getch();
}
#include<conio.h>
class student
{
char name[20];
int roll;
public:
void input()
{
cout<<"Enter Name";
cin>>name;
cout<<"Enter Roll No.";
cin>>roll;
}
void display()
{
cout<<"Student details";
cout<<"Name:"<<name;
cout<<"\nRoll No."<<roll;
}
};
class subject:private student
{
char sub[20];
public:
void input()
{
student::input();
cout<<"Enter subject";
cin>>sub;
}
void display()
{
student::display();
cout<<"\nSubject"<<sub;
}
};
void main()
{
subject ob;
ob.input();
ob.display();
getch();
}