OPERATOR OVERLOAD in C++


One important advantage of C++ is the OPERATOR OVERLOAD. Different functions can have the same name provided something allows to distinguish between them: number of parameters, type of parameters...

#include <iostream.h>

double test (double a, double b)
{
return a + b;
}

int test (int a, int b)
{
return a - b;
}

void main ()
{
double m = 7, n = 4;
int k = 5, p = 3;

cout << test(m, n) << " , " << test(k, p) << endl;
}



Added on June 22, 2007 Comment
}