#include <iostream>
#include <string>
using namespace std;
class Employee{
  private:
  string name;
  int empid;
  public:
  Employee(){
  }
  virtual float salary(){
  return 0;
  }
  void setName(string n){
  name=n;
  }
  void setEmpid(int id){
  empid=id;
  }
};
class Regular :public Employee{
  private:
  float basic_salary;
  public:
  Regular(float bs){
  basic_salary=bs;
  }
  float salary(){
  float DA=basic_salary*0.1;
  float HRA=basic_salary*0.3;
  return basic_salary+ DA + HRA;
  }
};
class Adhoc:public Employee{
  private:
  int num;
  float wages_amount;
  public:
  Adhoc(float wa){
  wages_amount=wa;
  }
  float salary(){
  return num*wages_amount;
  }
  void days(int n){
  this->num=n;
  }
};
int main(){
Regular r(10000);
r.setName("John");
r.setEmpid(1234);
cout<<"The salary of Regular employee: "<<r.salary()<<endl;
Adhoc ad(20);
ad.setName("Joan");
ad.setEmpid(5678);
ad.days(7);
cout<<"The salary of Adhoc employee: "<<ad.salary()<<"\n";
return 0;
}
Comments
Leave a comment