Where in the process of creating the program, the compiler, linker, etc. Is overriding functions and operator overloading?
I am particularly interested where this is done in C ++, Ruby and Python.
The overload function is (at least in C ++) internally processed inside the compiler. The idea is that the code that the compiler ultimately generates will be hard-coded to call the corresponding function, as if all functions had different names, and you called a function that is unique to the arguments. More generally, in most compiled languages that support overloading, overload resolution is performed at compile time, and the emitted code always calls the specified function. For example, Haskell supports compile-time overloading in this way.
Operator overloading is a special case of general overloading, so it is usually handled the same way.
(, , ) , , . , , .
, , . , .
++ , , , . ++ , , +, -, * .., , operator, . , , operator+ ,
+
-
*
operator
operator+
my_type operator+(const my_type& lhs, const my_type& rhs);
operator+ , operator+, ++ . , C ++ , .
, C, , , C- , .
Python is not bound / not compiled, it is interpreted. Thus, normal redefinition is performed when analyzing class sources. Of course, because of the dynamic nature, you can always redefine during operation. I believe that alternative implementations using byto-code compilation do this at compile time.
I also believe that the above is true for Ruby.