c++ - ((int) 和 (int(a)) 之间有什么区别?

标签 c++ c type-conversion

((int) a) 和有什么区别和 (int(a)) ?

第二个表达式在纯“С”中有效吗?

最佳答案

它们在 C++ 中没有区别。但是,C 仅支持第一个强制转换操作。

请参阅来自 tutorial 的此示例:

double x = 10.3;
int y;
y = (int) x;    // c-like cast notation 
y = int (x);    // functional notation

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

相关文章:

c++ - 使用Qt5解析以括号 `[`开头的JSON

c++ - 是否可以通过在单元测试中定义我自己的 PRIVATE 宏来公开私有(private)成员?

c++ - 是否可以在成员例程中使用 const_cast 来避免重复代码

c - 在 LPC XpressO 而不是 Arduino 上使用 LPC link2 与 esp8266 交互

c - 使用常量空间的 fprintf

c - C : good, 中的继承不好,还是其他?

postgresql - 在 PostgreSQL 中将数字列设置为同等格式的 varchar 货币列

Golang 类型在指向一种类型 slice 的指针 slice 与另一种类型 slice 之间的类型转换

c++ - QtCreator 找不到cmake

c# - 为什么 Convert.ToDouble 将我的值更改为 1000 倍?