double b;
int d;
int a = 10;
b = (double)a; // C 风格的强制转换,将整数 a 转换为浮点数 b
b = static_cast<double>(a);
int* ptr=nullptr;
ptr = (int*)malloc(sizeof(int)); // C 风格的强制转换,将 malloc 返回的 void 指针转换为 int 指针##
ptr = static_cast<int*>(malloc(sizeof(int)));
double c = 3.14;
d = (int)c;
d = static_cast<int>(c); // 将浮点数c转换为整数d
02-21
1273
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)