The error of "} expected" appears at line 5.
Why is that? I have included it at line 12.

The error of "Declaration missing ;" appears at line 8.
Why? There is ";" at the end of the line.

class PEmployee
{
public:
PEmployee();
PEmployee(string employee_name, double initial_salary);
void set_salary(double new_salary);
double get_salary() const;
string get_name() const;
private:
Person person_data;
double salary;
};

int main()
{
PEmployee f("Patrick", 1000.00);
cout << f.get_name() << " earns a salary of "
<< f.get_salary() << endl;
return 0;
}

Hi DeHF,
In your code there is no definition for get_name() and get_salary() function, no initialization in constructor. I modified as below and its behaving fine as u expecting,

#include <iostream>
#include <string>

using namespace std;

class PEmployee
{
public:
    //PEmployee();
    string Name;
    double Salary;
    //Initialization of variable in constructor
    PEmployee(string employee_name, double initial_salary)
    {
        Name = employee_name;
        Salary = initial_salary;
    }
    void set_salary(double new_salary);
    double get_salary() const;
    string get_name() const;
private:
    //Person person_data;
    double salary;
};

//Function definition
double PEmployee:: get_salary() const
{
    return Salary;
}
//Function definition
string PEmployee::get_name()const
{
    return Name;
}

int main()
{
    //PEmployee f;
    PEmployee f("Patrick", 1000.00);
    cout << f.get_name() << " earns a salary of "
        << f.get_salary() << endl;
    return 0;
}

Edited 4 Years Ago by Perry31

Comments
Thank you for finishing his homework for him. Hope you get a good grade.
This article has been dead for over six months. Start a new discussion instead.