Overloading Functions
In this lesson, we'll see the same function perform different operations based on its arguments.
We'll cover the following...
Each function has a specific number of arguments which have to be passed when calling it. If we increase or decrease the number of arguments in the call, we’ll get a compilation error:
Press + to interact
#include <iostream>using namespace std;double product(double x, double y){return x * y;}int main() {cout << product(10, 20) << endl; // Works finecout << product(10) << endl; // Error!}
The compiler doesn’t know how to handle arguments it wasn’t expecting. However, one of the coolest things we can do with functions is that we can overload them.
What is Overloading?
Overloading ...