Override, Override and Hide

a. The characteristics of member functions being overloaded :

(1) In the same scope (in the same class)

(2) The function name is the same

(3) The parameters are different

(4) The virtual keyword is optional

b. Override refers to the function of the derived class to override the function of the base class, and the characteristics are:

(1) Different scopes (in the base class and the derived class, respectively)

(2) The function name is the same

(3) The parameters are the same

(4) The base class function must have the virtual keyword

c. Hiding means that the function of the derived class shields the function of the base class with the same name. The rules are as follows:

(1) If the function of the derived class has the same name as the function of the base class, but the parameters are different. At this point, regardless of whether there is a virtual keyword or not, the functions of the base class will be hidden (still exist) (note the difference from overloading)

(2) If the function of the derived class has the same name and the same parameters as the function of the base class, but the function of the base class does not have the virtual keyword. At this point, the functions of the base class will be hidden (still exist) (note the difference from overwriting)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325891579&siteId=291194637