This is my first attempt at creating a class. I am a little frustrated because I still have errors that I don't understand. What am I doing wrong? Help!
Code:
#include "stdafx.h"
#include <iostream>
using namespace std;
using std::cout;
using std::endl;
//Class to calculate pay for an employee
class Employee
{
// data declaration section
private:
int _empId;
double _payRate;
double _hoursWorked;
//methods declaration section
public:
Employee();
void showEmployeeValues();
void setNewEmployeeValues();
void calculatePayValues();
};
// methods implementation section
Employee::Employee()
{
_empId = 1;
_payRate = 5.33;
_hoursWorked = 10.0;
cout << "Employee default constructor created. \n\n";
}
// Calculate pay for an employee
void Employee::showEmployeeValues()
{
cout<< " _empId = " << empId;
<< "\n _payRate = << payRate;
<< "\n _hoursWorked = << hoursWorked<< endl;
}
void Employee::calculatePayValues()
{
cout << empId * payRate * hoursWorked;
}
int main()
{
Employee payOne;
cout << "The value for this pay period is: \b";
payOne.showEmployeevaules();
cout << "\nThe pay amount is: ";
return 0;
}
The errors are:
error C2065: 'empId' : undeclared identifier
error C2593: 'operator <<' is ambiguous
error C2001: newline in constant
error C2143: syntax error : missing ';' before '<<'
error C2065: 'hoursWorked' : undeclared identifier
error C3861: 'empId': identifier not found, even with argument-
dependent lookup
error C2039: 'showEmployeevaules' : is not a member
of 'Employee'