c++ - 类型转换和类型转换之间有什么区别吗?

标签 c++ type-conversion casting

c++中类型转换和类型转换有区别吗

最佳答案

一般来说,casting是指显式转换,无论是C风格的cast(T(v) or (T)v)还是C++风格的cast (static_castconst_castdynamic_castreinterpret_cast)。转换通常是一个更通用的术语,用于任何时候将变量转换为另一个变量:

std::string s = "foo"; // Conversion from char[] to char* to std::string
int i = 4.3; // Conversion from float to int
float *f = reinterpret_cast<float*>(&i); // (illegal) conversion from int* to float*

关于c++ - 类型转换和类型转换之间有什么区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1374325/

相关文章:

返回中的 C++ 类型转换优先级

c++ - std::vector 在末尾移动反向迭代器

c++ - 是否保证浮点变量的拷贝按位相当于原始变量?

c++ - 是否存在绝对需要 typedef 的情况?

c - 当 int32_t 为扩展整数类型且 int 为 32 位补码标准整数类型时,(INT32_MIN + 1) 是多少

ios - Objective-C 中的方法参数转换

c++ - 涉及指针和手动实现的矩阵类的问题

并发队列推送函数的 C++ 返回值

php - Laravel 打包 html 到 pdf

casting - 在 TypeScript 中构建具有属性的函数对象