Yes, C++ overloading is achieved by renaming the function name when compiling the source file into a target file. The compiler will decide to call you based on the parameters passed in when calling the function. Overloading that specific function is completed during the compilation phase, which is the so-called static polymorphism in C++.
There is also override in C++, which realizes dynamic polymorphism through virtual functions, inheritance, and pointer mechanisms, which is achieved through the virtual table of the runtime class.
It doesn’t matter. Such as the answer of @伊仙. , But it won’t work if the parameters are pointers of parent and child types respectively (references are okay).
Yes, for example this code.
The output is
Yes, C++ overloading is achieved by renaming the function name when compiling the source file into a target file. The compiler will decide to call you based on the parameters passed in when calling the function. Overloading that specific function is completed during the compilation phase, which is the so-called static polymorphism in C++.
There is also override in C++, which realizes dynamic polymorphism through virtual functions, inheritance, and pointer mechanisms, which is achieved through the virtual table of the runtime class.
It doesn’t matter. Such as the answer of @伊仙. ,
But it won’t work if the parameters are pointers of parent and child types respectively (references are okay).