1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
int main()
{
cout << fixed << setprecision(2);
cout << "\t\t\tAVENGERS ASSEMBLE" << endl;
Date birthSteve(1, 1, 1900);
Date hireSteve(1, 1, 2010);
Date birthThor(1, 1, 1900);
Date hireThor(1, 1, 2010);
Date birthVision(1, 1, 2015);
Date hireVision(1, 1, 2015);
Date birthBanner(1, 1, 1960);
Date hireBanner(1, 1, 2010);
SalariedEmployee salariedEmployee1("ICE BOX", "Steve Rodgers", "1234 Avengers Tower, NY", "202-366-4589", birthSteve, hireSteve, 500000);
SalariedEmployee salariedEmployee2("INFINITY", "Vision", "Jarvis Central Core", "101101001011", birthVision, hireVision);
HourlyEmployee hourlyEmployee1("MJOLNIR", "Thor Odinson", "768.3.24.891 Asguard", "896-455-6631", birthThor, hireThor, 40, 75000);
HourlyEmployee hourlyEmployee2("GAMMA", "Bruce Banner", "UNKNOWN", "412-896-7823", birthBanner, hireBanner, 40, 100000);
vector < Employee * > staff(4);
staff[0] = &salariedEmployee1;
staff[1] = &salariedEmployee2;
staff[2] = &hourlyEmployee1;
staff[3] = &hourlyEmployee2;
for (const Employee *staffPtr : staff)
virtualViaPointer(staffPtr);
cout << "\n\n" << endl;
system("pause");
}
void virtualViaPointer(const Employee * const baseClassPtr)
{
baseClassPtr->print();
}
double SalariedEmployee::getMonthsPay() const
{
return getWeeklySalary() * 4;
}
double HourlyEmployee::getMonthsPay() const
{
return ((getNumHours() * getHourlyRate()) * 4);
}
|