January 2016
Intermediate to advanced
304 pages
6h 17m
English
Somewhat similar to templates, function overloading is another way in which we can make code and classes more versatile. We've already used overloaded functions during the course of the book, but they were provided with the code base. So, let's take a quick look at them.
When we define functions, we set fixed parameter types. Here's an example:
void DoStuff(T parameter);
With this definition, we can only pass a parameter of the T type. What if we want a choice of parameters? What if we want to be able to pass parameters of type T or type Y. Well, we can redefine the function, setting the same return type and name, but with unique parameters:
void DoStuff(T parameter); void DoStuff(Y parameter);
We now have two function declarations ...
Read now
Unlock full access