Answer : In C++, polymorphism is a feature that allows the same function name or same operator to behave differently in different situations.
This program illustrates polymorphism using function overloading.
#include <iostream>
using namespace std;
int sum (int a, int b) {
return a + b;
}
float sum(float a, float b) {
return a + b;
}
int sum(int a, int b, int c) {
return a + b + c;
}
int main() {
cout << sum(2, 3) << endl; // calls int version
cout << sum(2.5, 3.5) << endl; // calls float version
cout << sum(1, 2, 3); // calls 3-parameter version
}