Thursday, January 22, 2009

function overloading blues in C++

Can I overload functions with different return types ?

I wanted to overload a function just by changing the return type of the function. Turns out that this is not allowed at all :(
So the following overloading will not work

double squareMe(int x);
int squareMe(int x);

Got my answer here.

One solution is to do this :

void squareMe(double & y, int x);
void squareMe(int & y, int x);



No comments: