#include #include // class declaration for the base class class One { protected: float a; public: One(float = 2); // constructor float f1(float); // a member function float f2(float); // another member function }; // class implementation for One One::One(float val) // constructor { a = val; } float One::f1(float num) // a member function { return(num/2); } float One::f2(float num) // another member function { return( pow(f1(num),2) ); // square the result of f1() } // class declaration for the derived class class Two : public One { public: float f1(float); // this overrides class One's f1() }; // class implementation for Two float Two::f1(float num) { return(num/3); } int main() { One object_1; // object_1 is an object of the base class Two object_2; // object_2 is an object of the derived class // call f2() using a base class object call cout << "The computed value using a base class object call is " << object_1.f2(12) << endl; // call f2() using a derived class object call cout << "The computed value using a derived class object call is " << object_2.f2(12) << endl; return 0; }