摘要:
In this case, Box need access to Cup.func, AND Cup need access to Box.func, both of which are private because I don't want any other class to have acc... 阅读全文
摘要:
http://stackoverflow.com/questions/27037744/why-doesnt-c-allow-rebinding-a-reference#1. The primary reason that the designer of C++ introduced referen... 阅读全文
摘要:
Telescoping constructor: see Effective Java 2nd Edition Item 2If you want to use telescoping constructor but your compiler does not support c++11 stan... 阅读全文
摘要:
Reference material:Thinking In C++ 2nd eidition chapter 5 section "Handle classes"If there's something need to be hidden from clients of the class (su... 阅读全文
摘要:
main.cpp 1 #include "Stack.h" 2 3 #include 4 5 using namespace std; 6 7 class Box { 8 public: 9 Box():data(0), ID(num++) { cout data = b.data;... 阅读全文
摘要:
类似的问题还有: why can't class template use Handle Class Pattern to hide its implementation? || why there are linker problems (undefined reference) to my cl... 阅读全文
摘要:
为什么会想到这个问题?因为我总是不自觉地将c++和java进行对比。java对这种情况的处理方式是constructor返回一个null,然后已经构造的objects交给Garbage Collector处理,那么c++没有Garbage Collector,会是怎么样的一种情况呢?为了找到这个问题... 阅读全文
摘要:
以前喜欢这样组织文件:myproject/src/moduleA放moduleA的所有cpp文件myproject/include/moduleA放moduleA的所有h文件对moduleB.C.D...类似的处理,但是仍然容易有name clashes最近发现在使用上述文件组织方式的情况下,用na... 阅读全文
摘要:
参考资料:http://stackoverflow.com/questions/1306778/c-virtual-pure-virtual-explained验证代码:#include using namespace std;class Base {public: virtual void ... 阅读全文
摘要:
http://www.cplusplus.com/reference/ios/ios/operator_not/http://stackoverflow.com/questions/8117566/why-istream-object-can-be-used-as-a-bool-expression... 阅读全文