Page 3 of 3

reply

Posted: Mon Sep 29, 2003 1:45 am
by Ashique Mahmood Rupam
Thanks for the suggestion though knew it already. It is obvious that if a funciton is overloaded for some types and I am passing a value of other type, then I should type cast. But, I did not ask what I should do when I get this message.
I see that math functions of judge's compiler are overloaded ( when I use <cmath> ). Should they be ? As C math functions are inherited as they were, they should not have been overloaded as they were not. I do not also see any specification by TC++PL stroustrup. Then why are they overloaded ?
So, exactly what I want to know is why they overload them. Is there any standard indication for it, which I could not find yet. What I know is C++ math libraries should be kept as it is in C.
No, fun is meant.

Posted: Mon Sep 29, 2003 6:58 am
by Krzysztof Duleba
They were not overloaded because it's not possible in C. Three verions were present, but with different names. So float-sqrt was declared as sqrtf, long double-sqrt was declared as sqrtl and user had to choose the best version.
cmath receclares sqrt as:
[cpp] inline float
sqrt(float __x)
{ return __builtin_sqrtf(__x); }

inline long double
sqrt(long double __x)
{ return __builtin_sqrtl(__x); }[/cpp]
to make use of overloading mechanism.