So I am learning about the basics of C++ programming and I'm currently learning about classes and separate compilation in C++. However, i can't figure out why I got this error and its driving me crazy. The error that would pop up would be "38 driver.cpp expected primary-expression before '<<' token" or "39 driver.cpp expected primary-expression before '.' token". I don't quite understand what it means even after googling it.
Heres my main
Code:
#include <iostream>
#include <string>
using namespace std;
#include "employee.h"
int main(){
Employee Emp;
float w, r;
string n, l, t;
int id;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "Please enter your first and last name into the program respectively.\n";
cin >> n >> l;
cout << "Please enter your ID number.\n";
cin >> id;
cout << "Please enter 'manager' if your title is manager, if not then just enter 'employee'. \n";
cin >> t;
cout << "How many hours have you worked?\n";
cin >> w;
r = 10.00;
Emp.setSalary(w, r);
cout << "Employee's name:" << Employee.getFirstName(n) << " " << Employee.getLastName(l) << endl;
cout << "Employee ID Number:" << Employee.getID(id) << endl;
cout << "Title in company: " << Employee.getTitle(t) << << endl;
cout << "Your salary for the week is: " << Employee.getSalary() << endl;
system ("PAUSE");
return 0;
}
my implementation file:
Code:
#include<iostream>
#include<string>
using namespace std;
#include "employee.h"
// Implementaion of Employee Class
//
void Employee::setEmp(string n, string l, string t, int id, float s){
f_name = n;
l_name = l;
title = t;
this->id = id;
salary = s;
}
void Employee::setSalary(float h_rate, float h_work){
h_rate = r;
h_work = w;
if (title == "employee"){
if (h_work > 0 && h_work < 40)
(h_work * h_rate) = salary;
else if (h_work > 40) {
overtime = h_work - 40;
h_work = h_work - overtime;
salary = (h_rate * h_work) + ((1.5 * h_rate) * overtime);}
}
else if (title == "manager")
if (h_work > 0 && h_work <= 40){
(h_work * (h_rate * 2)) = salary;}
else if (h_work > 40) {
overtime = h_work - 40;
h_work = h_work - overtime;
salary = ((2 * h_rate) * h_work) + (2.5 * h_rate) * overtime);}
}
}
string Employee::getFirstName() {
return f_name;
}
string Employee::getLastName() {
return l_name;
}
string Employee::getTitle() {
return title;
}
int Employee::getID(){
return id;
}
float Employee::getSalary(){
return salary;
}
and my header file
Code:
#ifndef EMPLOYEE_H
#define EMPLOYEE_H
#include<iostream>
#include<string>
using namespace std;
/*****************************************************************
* Version 2.0
******************************************************************/
const int W_H=40;
class Employee {
public:
// the first string is for setting an emplloyye's first name
// the sec........
// .....
void setEmp(string fname, string lname, string title, int id, float s);
//
// thsi methid is returning an employee's first name
string getFirstName(); // retrieves first name of employee
string getLastName(); // retrieves last name os employee
void setSalary(float h_rate, float h_work); // sets salary of employee
string getTitle(); // retrieves title of an employee
int getID(); // retrieves ID of an employee
float getSalary(); // retrieves the Salary of an employee
private:
string f_name;
string l_name;
int id;
string title;
float s;
float h_rate;
float h_work;
float overtime;
};//
//
//End of the class
//
#endif