c++
davidneusoft
这个作者很懒,什么都没留下…
展开
-
static_cast、dynamic_cast、reinterpret_cast、和const_cast
强制类型转换容易引发错误,所以被认为是一种丑陋的语法。C++中有一个观念:丑陋的语法就应该用丑陋的方式表达。所以,C++的转换操作符使用xxxx_cast()这种一种繁琐的形式。目的是为了让你在使用类型转换前三思而行,看看是不是又不需要类型转换的方法或设计。更重要的是,C风格的强制类型转换通常很难查找。而C++这四种转换操作符可以用最简单的search功能找到。所以更便于排错。这就是说,只要你在C转载 2008-06-26 13:18:00 · 315 阅读 · 0 评论 -
Dynamic/Static/Reinterpret/Const and Volatile Cast
Const and Volatile Cast The expression const_cast(v) can be used to change the "const" or "volatile" qualifiers of pointers or references. T must be a pointer, reference, or pointer to member type转载 2008-06-26 13:36:00 · 487 阅读 · 0 评论