Write a C++ program creating a class for workers mentioning their id, name and group to which they belong. Compute their weekly wages for the number of hours they work, fixing a nominal pay rate which is a sensitive data. Include the required Accessor and mutator member functions to set and display the wages.
#include <iostream>
using namespace std;
class worker {
public:
worker(int id, const string &name, const string &group) {
this->id = id;
this->name = name;
this->group = group;
}
double weekly_wage(int hours) {
// TODO impl...
}
private:
int id;
string name;
string group;
};
int main() {
worker w(23, "John", "P33312");
w.weekly_wage(40);
return 0;
}
Comments
Leave a comment