This is my header file.
[PHP]#include <string>
using std::string;
class Employee
{
public:
Employee(string,string,int) ;
void setFirstName( string );
string getFirstName();
void setLastName( string );
string getLastName();
void setMonthlySalary(int);
int getMonthlySalary();
private:
string Fname;
string Lname;
int Salary;
};[/PHP]
Below is my body file:
[PHP]#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include "employ.h"
Employee::Employee(string str, string obc, int range )
{
setFirstName(str);
setLastName(obc);
setMonthlySalary(range);
}
void Employee::setFirstName(string str)
{
Fname= str;
cout <<" Employee's first name is:" << str << endl;
}
// string Employee::getFirstName()
// {
// return Fname;
// }
void Employee::setLastName(string obc)
{
Lname= obc;
cout<<" Employee's last name is:" << obc <<endl;
}
//string Employee::getLastName()
//{
// return Lname;
// }
// int Employee::getMonthlySalary()
// {
// return Salary;
// }
void Employee::setMonthlySalary(int)
{
// range= Salary;
// if ( Salary < 0)
// Salary = 0;
// else
// {
// Salary=Salary;
cout<<"::::"<< Lname << ":" << Fname << " monthly salary is " << Salary << endl;
// }
} [/PHP]
and finally my main file
[PHP]
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include "employ.h"
int main()
{
Employee employ1(" Mike","Madox",700);
Employee employ2("Steven","Stevenson",800);
char holdscr;
std::cout << "\n\n\t*** Enter a character and press return to exit the program! ***\n\n\t"<< std::endl;
std::cin >> holdscr;
return 0;
}[/PHP]
First of, I have a couple questions. Why when i un comment the comment lines in my body does it have absolutely no effect on the outcome of the file. When i execute this file i get the correct, last name, first name, but for the int it gives me some crazy #'s and does not carry over what i typed in my main.
How can i fix this?