1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
void process(int i) {
std::cout << "Processing int: " << i << std::endl;
}
void process(double d) {
std::cout << "Processing double: " << d << std::endl;
}
int main() {
process(10); // Calls process(int)
process(3.14); // Calls process(double)
// process(5.0f); // Error: Ambiguity if float is passed (uncomment to see the error)
return 0;
}
Back to function_overloading