Suppose I have
I think it does. In Java it does but I am not sure about C++Code:int x;
int y;
double a;
double z;
a=<static_cast>(x)/y; // does this implicitly cast y to double
a=z/y; // does this implicitly cast y to double
Printable View
Suppose I have
I think it does. In Java it does but I am not sure about C++Code:int x;
int y;
double a;
double z;
a=<static_cast>(x)/y; // does this implicitly cast y to double
a=z/y; // does this implicitly cast y to double
orCode:static<cast>(x)/y;
are wrong. Did you mean:Code:<static_cast>(x)/y;
or something else?Code:static_cast<double>(x)/y;
If so, then I think yes, x is explicitly casted, and y is implicitly casted because the other operator argument is a double.
>In Java it does but I am not sure about C++
The result of an expression has the same type as the longest floatiest operand.
Thanks for the replies :)
:p
while we are on this topic.. i was taking a #2 ealier today.. and I was thinking about c++ programming.. and then i was thnking... "Is it necessary to typecast whilst using STL...???" Like.. if you divided two templated integers... would the template perform integer or floating point division...??
>i was taking a #2 ealier today..
Too much information.
>Is it necessary to typecast whilst using STL...???
If the situation warrants it, yes. But if you're using things properly these situations will be few and far between.
>Like.. if you divided two templated integers...
Can you show an example of what you mean?