<分区>
Possible Duplicate:
C++: What's the difference between function(myVar) and (function)myVar ?
我已经看到并使用了这些类型转换的两种变体:
int(floatvar)
(int)floatvar
这两者有什么区别吗?关于何时使用哪个有任何偏好吗?
<分区>
Possible Duplicate:
C++: What's the difference between function(myVar) and (function)myVar ?
我已经看到并使用了这些类型转换的两种变体:
int(floatvar)
(int)floatvar
这两者有什么区别吗?关于何时使用哪个有任何偏好吗?
最佳答案
它们之间没有区别。 (int)floatvar
是 C 的转换方式,其中 as int(floatvar)
是 C++ 方式(尽管最好是显式使用 static_cast<>
)。
关于c++ - int(floatvar) 和 (int)floatvar 之间有区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4497908/