Feature of overload of member functions: (1) Same range (in the same class); (2) Same function name; (3) Different parameters; (4) virtual keywords are optional. Override refers to the function of a derived class that overrides a base class function. The features are as follows: (1) different ranges (located in the derived class and the base class respectively); (2) the function name is the same; (3) the parameters are the same. (4) basic functions must have virtual keywords. "Hide" means that the function of the derived class shields the base class function with the same name. The rule is as follows: (1) if the function of the derived class has the same name as the base class function, but the parameter is different. In this case, functions of the base class will be hidden regardless of whether there is any virtual keyword (Be sure not to confuse them with overload ). (2) If the function of the derived class has the same name and parameter as the function of the base class, but the base class function does not have the virtual keyword. At this time, the base class functions are hidden (Be sure not to confuse with overwrite)
The key is that the following sentence helps me understand the specific reasons: these concepts are actually compiler problems.
Hidden (hide): indicates that the member functions of a derived class hide the member functions of a base class function. the word hidden can be understood as follows: when calling a class member function, the compiler will look up the function definition step by step along the inheritance chain of the class, if yes, the query is stopped. Therefore, if both a derived class and a base class have a function with the same name (whether or not the parameters are the same, the compiler finally selects the function in the derived class, so we can say that the member function of this derived class "hides" The member function of the base class, that is to say, it prevents the compiler from continuing to look up the function definition.
In polymorphism, the base class pointer can reference the override function in the derived class due to the virtual keyword modification. Under the link of the virtual table, use dynamic concatenation to find the corresponding function implementation in the required derived class.