Undefined variables in an Object

// This is a homework question so I don't need the solution, just help getting there...

How do I incorporate undefined variables for an Object and use them in calculations?

I need to write a program that calculates pay for hours worked under 40 and also overtime pay using Employee Objects. The hours worked and wage are user inputted. How do I declare the variable_name and construction parameters without knowing them?

Here's my code:

#include<iostream>
#include<string>

using namespace std;

#include "ccc_empl.h"

double salary = 0.0;
double hours = 0.0;
double pay = 0.0;
double ot_pay = 0.0;
double total_pay = 0.0;

int main()
{
cout << "Name of the employee: " << endl;
string name;
getline(cin, name);
cout << "Salary of the employee: " << endl;
cin >> salary;
cout << "Hours worked by employee: " << endl;
cin >> hours;

Employee name(name, salary); //This is what I don't understand.

double new_salary = name.get_salary() * hours;
name.set_salary(new_salary);

//Stopped here knowing I would get error messages and hoping that I could work through them. I obviously need more code to finish the problem...

system("pause");
return 0;
}
Last edited on
Do I need to pass the information into the Employee Object?
The line you've highlighted is creating an object called Employee. The name of the object your creating will be called "name" and your passing 2 variables through to the constructor (name and salary).

You only need to pass the information through if that's the design of the Employee object.
Topic archived. No new replies allowed.