C++ examples for Function:Function Overload
Demonstrate when a function is overloaded at compile time vs. overriden at runtime
#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; class Employee//from www . j a v a 2s. c o m { public: virtual void calcTuition() { cout << "We're in Employee::calcTuition" << endl; } }; class GraduateEmployee : public Employee { public: void calcTuition() { cout<<"We're in GraduateEmployee::calcTuition"<<endl; } }; void fn(Employee& x) { x.calcTuition(); // which calcTuition()? } int main(int nNumberofArgs, char* pszArgs[]) { Employee s; fn(s); GraduateEmployee gs; fn(gs); return 0; }