Robert
Robert

Reputation: 83

What is the issue in this inheritence cpp problem

class Temporary_Employee: public Employee{
    //consolidated monthly pay
    public:
        
    int con_pay;
    int sal;
    Temporary_Employee(string name,int num,string des,int cp) :Employee(name,num,des){
        con_pay=cp;
    }
        void salary(){
            sal=con_pay;
        }
        
        void display_t(){
            cout<<"Name: "<<employee_name<<endl;
            cout<<"Number: "<<employee_no<<endl;
            cout<<"Designation: "<<desig<<endl;
            cout<<"Monthly Salary: "<<sal<<endl;
        }
};

I'm getting error:'Employee::Employee(std::string, int, std::string)' is private within this context

Upvotes: 1

Views: 52

Answers (2)

Aniket Sinha
Aniket Sinha

Reputation: 235

It seems like you need make the data members in you "Employee" class as public. like this

Employee(...){
 public:
     {data members}
}

Upvotes: 2

DeathStroke5552
DeathStroke5552

Reputation: 43

The data members (name,num,des) in your 'Employee' class should be specified as public.

Upvotes: 2

Related Questions