//BCA Support
//www.bcasupport.xyz
#include <iostream.h>
#include <conio.h>
class employee
{
int id;
char name[20];
float salary;
protected:
void ComputePay(int hours)
{
salary=125*hours;
}
void input()
{
cout<<"\nEnter Employee ID = ";
cin>>id;
cout<<"Enter Name = ";
cin>>name;
}
void display()
{
cout<<"\nEmployee ID = "<<id;
cout<<"\nName = "<<name;
cout<<"\nWeekly Salary = Rs. "<<salary;
}
};
class male : employee
{
int hours;
public:
void salary()
{
input();
cout<<"Enter hours worked = ";
cin>>hours;
ComputePay(hours);
}
void output()
{
display();
}
};
class female : employee
{
public:
void salary()
{
input();
ComputePay(40);
}
void output()
{
display();
}
};
int main()
{
clrscr();
male m1;
m1.salary();
female f1;
f1.salary();
clrscr();
cout<<"\nEmployee Details -\n";
m1.output();
cout<<endl;
f1.output();
getch();
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.