#include<conio.h>
#include<iostream.h>
class student
{
private:
char name[20];
public:
void getname()
{
cout<<"\nEnter Name:";
cin.getline(name,20);
}
};
class roll: public student
{
private:
int rn;
public:
void getrn()
{
getname();
cout<<"\nRoll No.:";
cin>>rn;
}
};
class cor: public roll
{
private:
char course[10];
public:
void getcourse()
{
getrn();
cout<<"\nCourse Name:";
cin>>course;
}
void display()
{
cout<<name;
}
};
void main()
{
clrscr();
cor d;
d.getcourse();
d.display();
getch();
}
#include<iostream.h>
class student
{
private:
char name[20];
public:
void getname()
{
cout<<"\nEnter Name:";
cin.getline(name,20);
}
};
class roll: public student
{
private:
int rn;
public:
void getrn()
{
getname();
cout<<"\nRoll No.:";
cin>>rn;
}
};
class cor: public roll
{
private:
char course[10];
public:
void getcourse()
{
getrn();
cout<<"\nCourse Name:";
cin>>course;
}
void display()
{
cout<<name;
}
};
void main()
{
clrscr();
cor d;
d.getcourse();
d.display();
getch();
}
0 comments:
Post a Comment