Write a program using three or more class ♥
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<iomanip.h>
class per
{
private:
char name[20];
int age;
public:
per(char n[20],int a)
{
strcpy(name,n);
age=a;
}
void display()
{
cout<<"\n Name Is -->>: "<<setw(15)<<setfill('*')<<name;
cout<<"\n Age Is -->>: "<<setw(16)<<setfill('*')<<age;
}
};
class student:public per
{
private:
float perc;
public:
student(char n[20],int a,float p):per(n,a)
{
perc=p;
}
void display()
{
cout<<"\n Student";
per::display();
cout<<"\n Percentage Is-->>: "<<setw(10)<<setfill('*')<<perc;
}
};
class techer:public per
{
private:
float salary;
public:
techer (char n[20],int a,float s):per(n,a)
{
salary=s;
}
void display()
{
cout<<"\n Techer ";
per::display();
cout<<"\n Salary Is -->>: "<<setw(13)<<setfill('*')<<salary;
}
};
void main()
{
clrscr();
student s("mahi",22,99);
techer t("devershi",21,5000);
s. display();
t. display();
getch();
}
Here is the output :))
No comments:
Post a Comment