Here are the details of the assignment:
I am to write a program with a
class Worker
that has 3 private data members (int age, int yrsService, and string jobTitle).
Then there is to be 2 objects of Worker type; Jones and Smith.
Data members initialized are as follows: 25, 3, Sales and 37, 10, President.
The displayed results should look like:
Age: 25
Service: 3
Job: Sales
Age: 37
Service: 10
Job: President
Age: 26
Service: 4
Job: Sales
Age: 38
Service: 11
Job: President
Age: 27
Service: 5
Job: Sales
Age: 39
Service: 12
Job: President
I'm not sure where to go from this point. Is overloading unary operators basically just a counter increment?
Edit: Almost forgot my code...
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
|
#include<iostream>
#include<string>
using namespace std;
class Worker
{
public:
void printData() const
{
cout << "Age: " << age << endl;
cout << "Years of Service: " << yrsService << endl;
cout << "Job Title: " << jobTitle << endl;
}
private:
int age, yrsService;
string jobTitle;
};
int main()
{
return 0;
}
| |