#include<iostream.h>
#include<conio.h>
class employee
{
protected:
int emp_id;
char emp_name[20];
public:
void accept()
{
cout<<"Enter name and emp id=";
cin>>emp_name>>emp_id;
}
void display()
{
cout<<"Name="<<emp_name<<endl;
cout<<"ID="<<emp_id<<endl;
}
};
class worker:public employee
{
protected:
int salary;
public:
void accept1()
{
cout<<"Enter Salary=";
cin>>salary;
}
void display1()
{
cout<<"Salary:"<<salary<<endl;
}
};
void main()
{
clrscr();
worker w;
w.accept();
w.accept1();
w.display();
w.display1();
getch();
}
/*Output:
Enter name and emp id=qqq 123
Enter Salary=200
Name=qqq
ID=123
Salary:200
*/
#include<conio.h>
class employee
{
protected:
int emp_id;
char emp_name[20];
public:
void accept()
{
cout<<"Enter name and emp id=";
cin>>emp_name>>emp_id;
}
void display()
{
cout<<"Name="<<emp_name<<endl;
cout<<"ID="<<emp_id<<endl;
}
};
class worker:public employee
{
protected:
int salary;
public:
void accept1()
{
cout<<"Enter Salary=";
cin>>salary;
}
void display1()
{
cout<<"Salary:"<<salary<<endl;
}
};
void main()
{
clrscr();
worker w;
w.accept();
w.accept1();
w.display();
w.display1();
getch();
}
/*Output:
Enter name and emp id=qqq 123
Enter Salary=200
Name=qqq
ID=123
Salary:200
*/
No comments:
Post a Comment