OK. new easy question for you guys.
Code:
#include <iostream>
#include <stdlib.h>
class Employee//Class called employee
{
int Age;
int YearsOfService;
int Salary;
public:
Employee(): Age(18) ,YearsOfService(1) ,Salary(10000){} // Trying to make default values
Employee(int initialAge, int initialYearsOfService, int initialSalary); // constructor
~Employee(); // destructor
void SetAge(int age) {ItsAge = age; }
void SetYearsOfService(int YearsOfService) {ItsYearsOfService = YearsOfService; }
void SetSalary(int Salary) {ItsSalary = Salary; }
int GetAge() const { return ItsAge; }
int GetYearsOfService() const { return ItsYearsOfService ; }
int GetSalary() const { return ItsSalary; }
private:
int ItsAge;
int ItsYearsOfService;
int ItsSalary;
};
// Function definitions.
Employee::Employee (int initialAge,int initialYearsOfService,int initialSalary)
{
ItsAge = initialAge;
ItsYearsOfService = initialYearsOfService;
ItsSalary = initialSalary;
}
Employee::~Employee() // takes no action
{
}
int main()
{
Employee JohnFKennedy(36,4,2000);
Employee Tom;
std::cout<<"\nJohn F. Kennedy's Age is: "<<JohnFKennedy.GetAge();
std::cout<<"\nJohn F. Kennedy's sallary is: $"<<JohnFKennedy.GetSalary();
std::cout<<"\nJohn F. Kennedy's Years of service is: "<<JohnFKennedy.GetYearsOfService();
std::cout<<"\nTom's Age is: "<<Tom.GetAge();
std::cout<<"\nTom's sallary is: $"<<Tom.GetSalary();
std::cout<<"\nToms's Years of service is: "<< Tom.GetYearsOfService();
std::cout<<"\n";
system("pause");
return 0;
}
OK. The problem. when i create a new object, i want the values to be default. But i get this random number instead. what am i doing wrong?