Thursday, August 18, 2022

QUESTION OF SALARY OF EMPLOYEE

 #include<iostream>

using namespace std;


class employee

{

    private:

    int eid;

    string name;

    public:

    employee(int eid,string name)

    {

        eid=e;

        name=n;

    }

    int getemployeeID()

    {

        return eid;

    }

    string getname()

    {

        return name;

    }

};

class fulltime employee:public employee

{

    private:

    int salary;

    public:

    fulltime employee(int e,sting n,int sal):employee (e,n)

    {

      salary =sal;   

    }

    int getsalary()

    {

        return salary;

    }

};

class parttime employee:public employee

{

    private:

    int wage;

    public:

    parttime employee(int e,string n,int w):employee (e,n)

    {

        wage=w;

    }

    int getwage()

    {

        return wage;

    }

};


int main()

{

    parttime employee p1(1,"john",500);

    fulltime employee p2(2,"hima",400);

    cout<<"Salary of "<<p2.getName()<<" is "<<p2.getSalary()<<endl;

    cout<<"Daily wage of "<<p1.getName()<<" is "<<p1.getWage()<<endl;

}

No comments:

Post a Comment

CONSTRUCTURE IN PARENT CLASS

class Parent {     public Parent()     {         System.out.println("Parent Constrcutor");     }              } class Child extend...