How inheritance, encapsulation and polymorphism work in C++
May 20, 2009, 12:03 (5 Talkback[s])
(Other stories by Alexander Sandler)
WEBINAR: On-demand webcast
How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >
[ Thanks to Alexander
Sandler for this link. ]
"How overloading works
"Another thing that we have to take care of in C++ is how to
distinguish between some_function() and
some_class::some_function(). Or between some_class::some_function(
int ) and some_class::some_function() I.e. what's the difference
between two methods with the same name that receive different
number and type of arguments? What is the difference between method
and function that has same name?
"Obviously, out of linker, compiler and preprocessor, linker is
the one that should be aware of the above difference. This is
because we may have some_function() in some distant object file.
Linker is the component that should find this distant function and
interconnect the call to the function and the actual function.
Linker uses function name as a unique identifier of the
"To make things work, g++ and any other modern compiler, mangles
the name of the method/function and makes sure that:
1. Mangled method name includes name of the class it belongs to
(if it belongs to any class).
2. Mangled method name includes number and type of arguments method
3. Mangled method name includes namespace it belongs to."