摘要:
casting: old style:int a = int (b);//b is doubleint a = (int) b; // b is double new cast:const_cast(expression)dynamic_cast(expression)reinterpret... 阅读全文
posted @ 2014-07-11 03:08
williamwood
阅读(129)
评论(0)
推荐(0)
摘要:
因为构造和析构函数有开销,所以也许前面定义了,还没用函数就退出了。所以比较好的方法是用到了才定义。 阅读全文
posted @ 2014-07-11 03:01
williamwood
阅读(170)
评论(0)
推荐(0)
effective c++ 条款24 declare non member functions when type conversions should apply to all parameters
摘要:
文中这个例子好像不具一般性。 有些时候会需要让class支持隐士类型转换(一般来说这不是个好主意)。 比如说有理数Rational 这个class, class Rational{ public: Rational(int real=0, int img=0) { this... 阅读全文
posted @ 2014-07-11 02:56
williamwood
阅读(123)
评论(0)
推荐(0)
浙公网安备 33010602011771号