# Include "stdafx. H "# include <iostream> using namespace STD; class base {public: int func () {return 100;} private :}; class derived: public base {public: int func () {int TEM; TEM = base: func (); // You can explicitly call the methods in the base class (otherwise, infinitely recursive calls) cout <tem <Endl; return 0 ;}}; int main () {derived OBJ; obj. func (); int TEM; TEM = base: func (); // cout <tem <Endl; System ("pause "); return 0 ;}
The first call in the code above is correct, and the second call is wrong. Why?
Although the first call does not seem to use an object, in fact, the call object exists here, because the subclass object contains the parent class object, the call here can be equivalent(Base *) This-> func ();
The second call is obviously not the same as the call object.
Summary:
Class member functions must be called with explicit or implicit call objects;
class member functions are not the same as common functions,