Search code examples
c++language-featurestypecast-operator

Is there a difference between int(floatvar) and (int)floatvar?


Possible Duplicate:
C++: What's the difference between function(myVar) and (function)myVar ?

I have seen and used both variants of these typecasts:

int(floatvar)

(int)floatvar

Is there any difference between the two? Are there any preferences about when to use which?


Solution

  • There is no difference between them. (int)floatvar is C way of doing the cast where as int(floatvar) is the C++ way (Although it is better to be explicit and use static_cast<>).