This is a simple code that demonstrates the use of a user made "round" function, but i'm running into a problem with the type cast in this program. I've written a program that avoids the type cast, but it's driving me crazy not being able to figure out exactly why this particular program isn't running.
The problem sems to actually be a compiler bug - there is a round function defined in <cmath> and your function is being considered an overload of it. Give your function a different name or put it in its own namespace to work around the compiler bug.
Is it really considered a compiler bug? I mean, isn't one of the reasons of using std:: instead of usingnamespace std this specific reason, so it doesnt become ambiguous ?
@SoloPopo: Because whole numbers should be stored in integers, not floating point types.
@TarikNeaj: if you delete usingnamespace std; the error still occurs. This would make sense for <math.h> but not for <cmath>. http://ideone.com/QIG8vl http://coliru.stacked-crooked.com/a/ac98e0845d535c15
The fact that is happens for two compilers in two standard library implementations makes me doubt it is a bug, but it doesn't make sense for it not to be.