Tutorial by Examples

Function overloading is having multiple functions declared in the same scope with the exact same name exist in the same place (known as scope) differing only in their signature, meaning the arguments they accept. Suppose you are writing a series of functions for generalized printing capabilities, b...
Note that you cannot overload a function based on its return type. For example: // WRONG CODE std::string getValue() { return "hello"; } int getValue() { return 0; } int x = getValue(); This will cause a compilation error as the compiler will not be able to work out wh...
Functions within a class can be overloaded for when they are accessed through a cv-qualified reference to that class; this is most commonly used to overload for const, but can be used to overload for volatile and const volatile, too. This is because all non-static member functions take this as a hi...

Page 1 of 1