* kien:
i.e. getmax(long, int) or getmax(int, long) will return in long data type?
You can't do that easily in the general case, but for the specific case
you can simply define a non-template overload:
long mymax( long a, long b ){ return mymax<long>( a, b ); }
which invokes the usual integer promotion rules for the arguments.
That doesn't work in the general case because with more than one overload
the arguments don't unambigiously select just one of them.
For the general case I guess you could make a macro that expanded the simple
call to something. But the sun's been turned on outside, so I think I'll
check out the fine wheather rather than tinkering with this problem. No way
to know when they'll turn it off again.
Btw., style, when did you last see "getsin", "getcos", and so forth in the
standard lib?
and how do we check what data type something runtime in c++?
At runtime, typeid, dynamic_cast, and RTTI in general.
Doesn't help you with template parameters, though, since they are compile-time.
And usually it's much better to use virtual functions than manual type checking.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?