Demonstrates how to create multiple functions with the same name but different parameters.
cppCopy code#include <iostream>
void print(int i) {
std::cout << "Integer: " << i << std::endl;
}
void print(double d) {
std::cout << "Double: " << d << std::endl;
}
int main() {
print(5); // Calls print(int)
print(5.5); // Calls print(double)
return 0;
}
Leave a Reply