摘要:
1 class DoSomething { 2 private: 3 char * text; 4 //... 5 public: 6 DoSomething():text(nullptr) {} 7 }; 对私有成员的初始化发生在花括号之前(调用=defalut初始化),C++有时会在你没有显式的 阅读全文
摘要:
2.1.将某些东西声明为const可帮助编译器侦测出错误用法。比如说,一个重载[]函数返回值用上const限定符表明了其不可写值的特性。 1 const char& operator[](size_t rank) { 2 return text[rank]; 3 } 2.2.将const作用于函数, 阅读全文