Hello Everyone,
I just started to program and I'm having a bit difficult with it.
Can someone run this code and please explain to me these errors and why they are not compiling.
Error 1 error C2228: left of '.setFirstName' must have class/struct/union c:\documents and settings\administrator\my documents\visual studio 2008\projects\projec314p\projec314p\project314p.cpp 71
Error 2 error C2228: left of '.displayMessage' must have class/struct/union c:\documents and settings\administrator\my documents\visual studio 2008\projects\projec314p\projec314p\project314p.cpp 72
#include <iostream>
#include <string>
using namespace std;
//Employee class
class Employee
{
public:
//constructor
Employee(string fname, string lname)
{
setFirstName(fname);
setLastName(lname);
}
void setFirstName(string fname)
{
FirstName = fname;
}
string getFirstName()
{
return FirstName;
}
void setLastName(string lname)
{
LastName = lname;
}
string getLastName()
{
return LastName;
}
void displayMessage()
{
cout << "Please enter your first name " << getFirstName() << endl;
cout << "Please enter your last name " << getLastName() << endl;
};
private:
string FirstName;
string LastName;
int salary;
};
int main()
{
string firstname;
string lastname;
string salary;
int salary1;
Employee myEmployee1();
Employee myEmployee2();
cout << "Your first name is " << endl;
myEmployee1.setFirstName(firstname);
myEmployee1.displayMessage();
cout << "Your last name is " << endl;
myEmployee2.setLastName(lastname);
myEmployee2.displayMessage();
cout << "You make how much an hour? " << getline(cin, salary)<< endl;
salary1 = salary * 40 * 4;
if (salary % 2)
salary = salary1 * .1;
cout <<"Your monthly earnings are " << salary << endl;
if (salary % 1)
salary = salary1 * 0;
cout <<"Your monthly earnings are " << salary << " too bad" << endl;
return 0;
}