2012年10月31日

c++类型转换

摘要: const_cast最普通的用途就是转换掉对象的 const 属性。class Widget { ... }; class SpecialWidget: public Widget { ... }; void update(SpecialWidget *psw); SpecialWidget sw; // sw 是一个非 const 对象。 const SpecialWidget& csw = sw; // csw 是 sw的一个引用 它是一个 const 对象 update(&csw); // 错误!不能传递一个 const SpecialWidget*... 阅读全文

posted @ 2012-10-31 10:32 GIS-MAN 阅读(156) 评论(0) 推荐(0) 编辑

导航