Const-cast Typecast
来源:互联网 发布:交互设计软件 html 编辑:程序博客网 时间:2024/06/09 23:39
Const-cast TypecastConst casts areonly available in C++. Const casts are used to strip the const-ness or volatile-ness from a variable. Const casts should be used sparingly;one example of a valid use of a const-cast is to strip the const-ness of a pointer to pass it into a function when you are certain the function will not modify the variable but the function designer did not specify the input as const.
const_cast<<type>>(<value>);
This example casts a const pointer to a non-const pointer to pass into a function: void func(char *);
const char *x = "abcd";
func(const_cast<char *>(x));
const_cast<<type>>(<value>);
This example casts a const pointer to a non-const pointer to pass into a function: void func(char *);
const char *x = "abcd";
func(const_cast<char *>(x));
- Const-cast Typecast
- Invalid typecast
- 标准C++的类型转换符:static cast、dynamic cast、reinterpret cast和const cast
- 标准C++的类型转换符:static cast、dynamic cast、reinterpret cast和const cast
- Dynamic/Static/Reinterpret/Const and Volatile Cast
- static_cast dynamic_cast const-cast reinterpret_cast的用法
- 各种 cast dynamic,static ,const,reinterpret
- Sample 3.14:typecast.cpp
- TypeCast Any AnyObject
- TypeCast overload 和 function object
- Dynamic/Static/Reinterpret/Const and Volatile Cast (English)
- C++类型cast之static/dynamic/reinterpret/const
- cast
- CAST
- cast
- Cast
- cast
- Cast
- NET命令
- 多情微软无穷贱!中了暗算的中国有多痛?
- 房价 物价飞涨的根本原因
- Qt使用浏览器
- QLabel函数重载,在图片上显示文字
- Const-cast Typecast
- 左右法则——复杂指针解析
- [转]年度最佳幽默
- 如何跨线程调用Windows窗体控件
- 进入云计算的世界
- 个人知识管理的29条原则
- [原创]Linux(ubuntu)环境变量设置
- [原创]Qt显示MessageBox对话框程序
- [原创]QT for Linux(ubuntu)编程常见问题总结