Re: [Dev-C++] Derived Class not redefining function
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2003-10-17 16:11:57
|
If you look a bit closer at the two methods, you will notice the different
signatures
Employee::printCheck() is const
HourlyEmployee::printCheck() isn't const
/Per W
On Fri, 17 Oct 2003, Opacki, Joseph wrote:
> 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
>
>
> -------------------------------------------------------
> This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo
> The Event For Linux Datacenter Solutions & Strategies in The Enterprise
> Linux in the Boardroom; in the Front Office; & in the Server Room
> http://www.enterpriselinuxforum.com
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|