#include <iostream>
#include <string>
using namespace std;
void fred(int a)
{
cout << "fred the first, " << a << endl;
}
void fred(int a, string b)
{
cout << "I am the second fred: " << a << " " << b << endl;
}
void fred(string c, string d = "ding!")
{
cout << "Lo, I am fred tertiary. " << c << " " << d << endl;
}
int main()
{
fred(17);
fred("this");
fred(24, "hours");
fred("some", "day");
}
As in Java, a function name may be reused with
different parameter types. While this may seem
commonplace, not every language allows it. Plain C and other
older compiled languages do not, and it's not really possible
in dynamically-typed languages like Python.
Textbook: pp. 256–257