dynamic_cast < type-name> (expression)
const_cast < type-name > (expression)
using std::cout;
using std::endl;
void change(const int *pt, int n);
int main()
{
int pop1 = 38383;
const int pop2 = 2000;
cout << "pop1,pop2: " << pop1 << " , " << pop2 << endl;
change(&pop1, -103);
change(&pop2, -103);
cout << " pop1, pop2: " << pop1 << " , " << pop2 << endl;
system("pause");
return 0;
}
void change(const int *pt, int n) {
int *pc;
pc = const_cast<int *>(pt);
*pc += n;
}
pop1,pop2: 38383 , 2000 pop1, pop2: 38280 , 2000 请按任意键继续. . .
static_cast< type-name > (expression)
High bar; Low blow; ... High *pb = static_cast<High *>( &blow) //合法 Low *pl = static_cast< Low *> (&bar) //合法 Pond *pmer = static_cast< Pond * > (& blow) ;//非法
reinterpret_cast < type-name >(expression)
struct dat {short a;short b;} ;
long value = 0xA224B118;
dat * pd = reinterpret_cast <dat *> (&value);
cout <<hex <<pd->a ; //显示前2个字节的值
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有