Hi
When I run this program instead of getting the values I initialized with the constructor, I get -858993460. I guess it's wrapping around in some way. Anybody have an idea?
Thanks for your help
#include <iostream>
using namespace std;
class Employee
{
public:
Employee(int Age, int Years, int Salary);
~Employee();
int GetAge();
int GetYears();
int GetSalary();
void SetAge(int itsAge);
void SetYears(int itsYears);
void SetSalary(int itsSalary);
private:
int itsAge, itsYears, itsSalary;
};
Employee::Employee (int Age, int Years, int Salary) {Age = itsAge; Years = itsYears; Salary = itsSalary; cout << "Constructor\n" ;}
Employee::~Employee(){cout << "Destructor\n";}
int Employee::GetAge() {return itsAge;}
int Employee::GetYears() {return itsYears;}
int Employee::GetSalary() {return itsSalary;}
void Employee::SetAge(int Age) {Age = itsAge;}
void Employee::SetYears(int Years) {Years = itsYears;}
void Employee::SetSalary(int Salary) {Salary = itsSalary;}
int main()
{
Employee Brian (5,1,100000);
Employee Stewey (1,0,50000);
Employee Peter (40,25,12000);
std::cout << "Brian: \t\tAged:\t\t"; std::cout << Brian.GetAge() << ".\n";
std::cout << "\t\tYears Worked:\t"; std::cout << Brian.GetYears() << ".\n";
std::cout << "\t\tEarns:\t\t"; std::cout << Brian.GetSalary() << ".\n";
std::cout << "Stewey: \tAged:\t\t"; std::cout << Stewey.GetAge() << ".\n";
std::cout << "\t\tYears Worked:\t"; std::cout << Stewey.GetYears() << ".\n";
std::cout << "\t\tEarns:\t\t"; std::cout << Stewey.GetSalary() << ".\n";
std::cout << "Peter: \t\tAged:\t\t"; std::cout << Peter.GetAge() << ".\n";
std::cout << "\t\tYears Worked:\t"; std::cout << Peter.GetYears() << ".\n";
std::cout << "\t\tEarns:\t\t"; std::cout << Peter.GetSalary() << ".\n";
return 0;
}