04 2011 档案

摘要:一些有用的c++ utility #define ITEMSOF(arr) (sizeof(arr) / sizeof(0[arr])) (0[arr] is identical to arr[0] for arrays but will intentionally fail i... 阅读全文
posted @ 2011-04-26 21:38 BiG5 阅读(311) 评论(0) 推荐(0)
摘要:c++中的位操作 使用or设置位 number |= 1 << x; 将设置位x 清除位 使用位操作&清除位。 number &= ~(1 << x); 这将清除位x。 转换位 XOR 操作 (^) number ^= 1 << x; 检查位 bit = number & (1 <... 阅读全文
posted @ 2011-04-26 21:12 BiG5 阅读(147) 评论(0) 推荐(0)
摘要:因为数组是根据指针来定义的,a[i]相当于*(a+i),这个满足交换律 阅读全文
posted @ 2011-04-24 23:54 BiG5 阅读(151) 评论(0) 推荐(0)
摘要:if s1 = "stackoverflow" then the following are some of its rotated versions: "tackoverflows" "ackoverflowst" "overflowstack" where as "stac... 阅读全文
posted @ 2011-04-24 23:48 BiG5 阅读(258) 评论(0) 推荐(0)
摘要://z 不用循环和条件判断打印1-1000 //z 2011-05-24 19:16:07@is2120 #include template struct NumberGeneration{ static void out(std::ostream& o... 阅读全文
posted @ 2011-04-24 23:28 BiG5 阅读(375) 评论(0) 推荐(0)
摘要:对于所有人都适用-参考手册 The C++ Programming Language (Bjarne Stroustrup) C++ Standard Library Tutorial and Reference(Nicolai Josuttis) The C++ IO... 阅读全文
posted @ 2011-04-24 23:00 BiG5 阅读(137) 评论(0) 推荐(0)
摘要:标准中对于类成员访问有如下说明: 3 If E1 has the type “pointer to class X,” then the expression E1->E2 is converted to the equivalent form (*(E1)).E2; 即对于指向c... 阅读全文
posted @ 2011-04-21 01:48 BiG5 阅读(173) 评论(0) 推荐(0)
摘要:通过一个非法的指针或者NULL指针调用成员函数会发生什么? #include struct foo { void bar () { std :: cout bar (); // (a) f -> baz (); // (b) } 我... 阅读全文
posted @ 2011-04-21 01:36 BiG5 阅读(191) 评论(0) 推荐(0)