I'm just getting started with classes and objects, and having a little trouble. I just filled out some of the basic parts of the program, because I figured I'd have trouble with the class/object implementation. I get the error "error C2228: left of '.determineSalary' must have class/struct/union type" in regards to line 23, which I've put a smiley next to. Edit: oops, didn't work out quite right, it's the line that says "companyPayroll.determineSalary();"
I'm not quite sure what the deal is, I've looked through my book, trying to figure it out, I thought it might have something to do with constructors...but I don't understand constructors that well yet either! Thanks guys/gals.
#include <iostream>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;
class Payroll
{
public:
void determineSalary();
}; //End class Payroll
int main()
{
Payroll companyPayroll();
companyPayroll.determineSalary();
void setPayroll();
return 0;
}
void Payroll::determineSalary() {
int paycode;
int hours;
double salary;
do {
cout << "Enter paycode (-1 to end):" << endl;
cin >> paycode;
switch (paycode) {
case 2:
cout << "Hourly worker selected\n";
cout << "Enter the hourly salary: \n";
cin >> salary;
cout << "Enter the total hours worked: \n";
cin >> hours;
cout << "Worker's pay is: " << salary * hours << "\n";
break;
} // End switch
}while (paycode != -1); // End do
} //End function determineSalary