// AmbiguousBinding - the situation gets confusing // when the compile time type and // run time type don't match #include #include class Student { public: double calcTuition() { return 0; } }; class GraduateStudent : public Student { public: double calcTuition() { return 1; } }; double fn(Student& fs) { // to which calcTuition() does this call refer? // which value is returned? return fs.calcTuition(); } int main(int nArgc, char* pszArgs[]) { // the following expression calls // fn() with a Student object Student s; cout << "The value of s.calcTuition when " << "called through fn() is " << fn(s) << "\n"; // the following expression calls // fn() with a GraduateStudent object GraduateStudent gs; cout << "The value of gs.calcTuition when " << "called through fn() is " << fn(gs) << "\n"; return 0; }