#include <iostream>
using namespace std;
class A
{
};
class B:public A
{
};
class C
{
};
int main(void)
{
double d = 6.6;
int i = static_cast<int>(d); //static_cast<数据类型>(数据) 转换内置数据类型
A *a = new A;
B *b = static_cast<B*>(a); //static_cast对有父子关系的类进行转换,没有继承关系不能转换
A *a2 = static_cast<A*>(b);
return 0;
}
C++显式类型转换笔记
最新推荐文章于 2024-05-30 23:47:56 发布