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
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.
My best code is written with the delete key.
Thanks for the replies
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...??
Last edited by The Brain; 09-09-2004 at 10:35 PM.
- "Problem Solving C++, The Object of Programming" -Walter Savitch
- "Data Structures and Other Objects using C++" -Walter Savitch
- "Assembly Language for Intel-Based Computers" -Kip Irvine
- "Programming Windows, 5th edition" -Charles Petzold
- "Visual C++ MFC Programming by Example" -John E. Swanke
- "Network Programming Windows" -Jones/Ohlund
- "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
- "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
>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?
My best code is written with the delete key.