gpt4 book ai didi

c++ - (T)value 和 T(value) 之间有什么区别?

转载 作者:太空狗 更新时间:2023-10-29 20:12:37 26 4
gpt4 key购买 nike

(T)valueT(value) 有什么区别?例如 (float)3.14float(3.14)。哪个更快或更好?

最佳答案

它们具有完全相同的作用和含义:

ISO/IEC 14882:2011 5.2.3 显式类型转换(函数符号):

A simple-type-specifier (7.1.6.2) or typename-specifier (14.6) followed by a parenthesized expression-list constructs a value of the specified type given the expression list. If the expression list is a single expression, the type conversion expression is equivalent (in definedness, and if defined in meaning) to the corresponding cast expression (5.4).

5.4 是“显式类型转换(强制转换符号)”,即 (T) 强制转换表达式

关于c++ - (T)value 和 T(value) 之间有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26432941/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com