Opacki, Joseph
2003-10-17 13:26:15 UTC
Can someone please tell me why my main() function isn't accepting the
redefined function of my base class? Everything seems to be compiling
correctly, but the base class printCheck function is executing and not the
derived class function.
Here are the excepts of code:
// -- BASE CLASS -- //
void Employee::printCheck() const
{
cout << "\nERROR: print_check FUNCTION CALLED FOR AN \n"
<< "UNDIFFERENTIATED EMPLOYEE. Aborting program.\n"
<< "Check with the author of the progrm about this bug.\n";
exit(1);
}
// -- DERIVED CLASS -- //
void HourlyEmployee::printCheck()
{
setNetPay(hours * wageRate);
cout <<
"\n__________________________________________________________\n";
cout << "Pay o the order of " << getName() << endl;
cout << "The sum of " << getNetPay() << " Dollars\n";
cout <<
"\n__________________________________________________________\n";
cout << "Check Stub: NOT NEGOTIABLE:\n";
cout << "Employee Number: " << getSSN() << endl;
cout << "Hourly employee.\n Hours Worked: " << hours
<< " Rate: " << wageRate << " Pay: " << getNetPay() << endl;
cout <<
"\n__________________________________________________________\n";
}
// -- MAIN -- //
HourlyEmployee joe;
joe.setName("Mighty Joe");
joe.setSSN("123-65-6547");
joe.setRate(50.20);
joe.setHours(40);
cout << "Check for " << joe.getName() << " for " << joe.getHours() << "
hours\n";
joe.printCheck();
^this call is where thing go crazy
redefined function of my base class? Everything seems to be compiling
correctly, but the base class printCheck function is executing and not the
derived class function.
Here are the excepts of code:
// -- BASE CLASS -- //
void Employee::printCheck() const
{
cout << "\nERROR: print_check FUNCTION CALLED FOR AN \n"
<< "UNDIFFERENTIATED EMPLOYEE. Aborting program.\n"
<< "Check with the author of the progrm about this bug.\n";
exit(1);
}
// -- DERIVED CLASS -- //
void HourlyEmployee::printCheck()
{
setNetPay(hours * wageRate);
cout <<
"\n__________________________________________________________\n";
cout << "Pay o the order of " << getName() << endl;
cout << "The sum of " << getNetPay() << " Dollars\n";
cout <<
"\n__________________________________________________________\n";
cout << "Check Stub: NOT NEGOTIABLE:\n";
cout << "Employee Number: " << getSSN() << endl;
cout << "Hourly employee.\n Hours Worked: " << hours
<< " Rate: " << wageRate << " Pay: " << getNetPay() << endl;
cout <<
"\n__________________________________________________________\n";
}
// -- MAIN -- //
HourlyEmployee joe;
joe.setName("Mighty Joe");
joe.setSSN("123-65-6547");
joe.setRate(50.20);
joe.setHours(40);
cout << "Check for " << joe.getName() << " for " << joe.getHours() << "
hours\n";
joe.printCheck();
^this call is where thing go crazy