Class help and set, get, retrieve

I am running into a little bit if trouble with my homework (not asking for a solution, just a push in the right direction).

Our directions are partly as follows;

"Write an employee class to encapsulate a users name, wage and
hours worked.

You should have get, set, and retrieve function for each
property, and functions that calculates their net pay
and gross pay.

Read in this information from the user, and display
their gross and net pay."


My code is below:
I believe I have a little grasp but I am getting no matching function to call for all of my set functions....and in int main cannot resolve address of overloaded function.

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
#include <iostream>
#include <string>

using namespace std;





class Employee {
private:
   int wages;
   int hours;
    

public:
   
   string firstName;
   
   void setName () {
      this->firstName = firstName;
   }
   
   void setHours () {
      this->hours = hours;
   }     
   
   void setWage () {
      this->wages = wages; 
   }
   
   void retrieve() {
        string temp;
        int temp1;
        
        cout << "What is your name?";
        cin >> firstName;
        setName(temp); 
    
        cout << "How many hours did you work?";
        cin >> hours;
        setHours(temp1);
    
        cout << "How much are you paid per hour?";
        cin >> wages;
        setWage(temp1);
    }   
    
    string getName() {
        return firstName;  }
        
    double getNet() {
        return (hours * wages) * .93;  }
        
    int getGross() {
        return hours * wages;  }
        
    
}    ;                

int main () {

    Employee test;
    test.retrieve;
    cout << "Hello " << test.getName () << "!\n";
    cout << "Your gross pay for the week is " << test.getGross() << ".\n";
    cout << "Your net pay is " << test.getNet() << ".\n";
    cout << "Don't spend it all in one place!!\n";
    
    return 0;

}
    
The problem is in your setters. You need to supply an parameter so they can store it.
Example:
1
2
3
4
void setName (string firstName)
{
   this->firstName = firstName;
}


Then of course you need to get the all the input.

1
2
3
string Name;
cout << "Name: ";
cin >> Name;


Then you can call test.setName(Name);
Awesome...was able to fix that and errors are gone....

I also was able to work through a couple errors I got after this just through previous help!
This site really is an awesome resource!

Thanks!!
You are very welcome.
Topic archived. No new replies allowed.