Three things:
1) It works fine for me. (I cannot replicate your error.)
2) You forgot to #include <limits>
3) You need to replicate line 22 before line 21 also.
Hope this helps.
Well, did three, and it worked. <limits> wasn't needed.
If you use numeric_limits, you need <limits>, whether your compiler complains or not.
Glad to have helped.
Duoas ..
it works without including <limits>..!!
I'm using DevC++
So?
It doesn't work with VC++ or C++Builder. Just because your compiler lets you get away with something doesn't mean you should do it.
I primarily use the GCC myself, and I've been bit by this very issue.
If you use numeric_limits, you need <limits>, whether your compiler complains or not.