C ++ hide
The overload of C ++ is that multiple functions in a class have the same name and meet the requirements of the overload. For example, the parameters are different.
The rewriting of C ++ must be that the parent class function has the virtual keyword. Subclasses can be rewritten.
If the function of the parent class does not have the virtual keyword. When a subclass is overwritten, It is not overwritten. It is hidden.
If the parent class has a virtual function.
To rewrite a subclass, the function name and parameters must be the same. If the parameters are not the same, it is not rewritten. It is hidden.
Hiding means hiding the actual function or the actual subclass type. Only interfaces defined by the outermost layer are exposed.
Hiding a function may cause an error for a friend who wants to use polymorphism. A parent class Pointer Points to a subclass object. After the hidden implementation, the function you call is not a subclass. It is the parent class.
This is because there are many inheritance in C ++. So without hiding, you cannot figure out which parent class function to call.
This problem does not exist in Java. Because it is a single inheritance. Subclass will only override the method of the parent class and will not hide it.