#include using namespace std; int sum(int one, int two){ return one + two; } int sum(int one, int two, int three) { return one + two + three; } /** * Will not work. * Changing only return type does not overload a function */ // double sum(int one, int two) { // return (double) (one + two); // } double sum(double one, double two) { return one + two; } double sum(double one, double two, double three) { return one + two + three; } int sum(int one, double two) { return one + (int)two; } double sum(double one, int two) { return one + (double)two; } template T sum(T one, T two) { return one + two; } template T sum(T one, T two, T three) { return one + two + three; } template T sum(T one, U two) { return one + (T)two; } int main() { cout << "sum(4, 5)= "<(4, 5)= "<(4,5)<(4.5, 5.0)= "<(4.5,5.0)<(4, 5, 9)= "<(4,5,9)<(4.5, 5.0, 9.0)= "<(4.5,5.0,9.0)<(4, 5.5)= "<(4,5.5)<(4.5, 5)= "<(4.5,5)<