@@ -242,9 +242,9 @@ \subsection{C++}
242242
243243\lstinputlisting [language={[KB]C++}, linerange={76-76}, style=codeStyle]{../codes/cpp/polymorphism/type_manip.cpp}
244244
245- There are two types of cast: at compilation time ( \keyword [C++]{static\_ cast}) or at runtime ( \keyword [C++]{dynamic\_ cast}) .
245+ There are two types of down-casting (among others): \keyword [C++]{static\_ cast} and \keyword [C++]{dynamic\_ cast}.
246246Using the first one, type check is performed during compilation.
247- The dynamic cast check types at runtime and return \keyword [C++]{NULL} in case of pointers, or throw an exception in case of references.
247+ The dynamic cast checks types at runtime and return \keyword [C++]{NULL} in case of pointers, or throw an exception in case of references.
248248
249249\lstinputlisting [language={[KB]C++}, linerange={83-87}, style=codeStyle]{../codes/cpp/polymorphism/type_manip.cpp}
250250
@@ -440,6 +440,27 @@ \subsection{Ruby}
440440
441441\section {Methods overloading }
442442
443+ It is the feature of a class having multiple methods defined by the same identifier and different parameters.
444+ Statically-typed programming languages are, usually, the ones affording methods overloading since they enforce type checking during function calls.
445+ In this section, we will verify these properties:
446+ \begin {itemize }
447+ \item If the programming language supports methods overloading.
448+ If not, how to afford something similar.
449+ \item If we can overload methods over inheritance
450+ \end {itemize }
451+ 452+ \subsection {C++ }
453+ 454+ In C++, overloading is permitted in the same class
455+ 456+ \lstinputlisting [language={[KB]C++}, linerange={4-8,16-18,22-23,31-32}, style=codeStyle]{../codes/cpp/polymorphism/overloading.cpp}
457+ 458+ When the same method is overloaded in a subclass, the new definition will hide those of the parent class;
459+ if they are called, this will generate a compilation error.
460+ To call them, there are two ways: import them using \keyword [C++]{using} declaration, or by calling them explicitly \citep {2009 -bailey }.
461+ \lstinputlisting [language={[KB]C++}, linerange={10-17,19-19,26-32}, style=codeStyle]{../codes/cpp/polymorphism/overloading.cpp}
462+ 463+ 443464
444465\section {Methods overriding }
445466
0 commit comments