Issue with class implementation

I was wondering if I could possibly get a little assistance with a homework assignment I am having a problem with? I am having an issue with class implementation and getting all members of a function to be implemented. Any assistance would be very appreciative.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <iostream>

using namespace std;

class Person
{
	public:								
	Person();							
	Person(string pname, int page);		
	string get_name() const;
	int get_age() const;

	// Other members...
	protected:
	string name;
	int age; // 0 if unknown
};

Person::Person(std::string pname,int page)
{
	name = pname;
	age = page;
}

string Person::get_name() const
{
	return name;
}

int Person::get_age() const
{
	return age;
}

class PEmployee 

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

PEmployee::PEmployee()
{
}

PEmployee::PEmployee(string employee_name, double initial_salary)
{
    name = employee_name ;
    salary = initial_salary ;
}

void PEmployee::set_salary(double new_salary)
{
    salary = new_salary;
}

string PEmployee::get_name() const
{
    return name;
}

double PEmployee::get_salary() const
{
    return salary;
}


int main()
{	
    PEmployee A("Jonathan", 25000.00);
    cout << A.get_name() << " earns a salary of "
    << A.get_salary() << endl;

	system("PAUSE");

    return 0;
}
Last edited on
what is the problem you are facing? You haven't defined the constructor Person();
That's the thing, I keep getting different errors after I fix something I thought needed to be fixed. I redefined Person and now am getting an error with PEmployee not being defined after taking out lines 36 to 38.
Last edited on
The class name should be PEmployee and not PEmploy. Instead of
class PEmploy
public:
PEmployee;
: public Person

{
try
class PEmployee
: public Person

{
I didn't catch that. Have been working on this for some time now. I changed my typing error and now in main, the name I used, get_name and get_salary are said to be inaccessible under lines 51, 69 and 74
there seems to be confusion between parent & child class definitions. following link may help you
http://www.cplusplus.com/doc/tutorial/polymorphism/
Topic archived. No new replies allowed.