effective c++中const的理解
const char& operator[] (std::size_t position) const //问下前面的那个const有什么用阿 ?去掉的话会error: invalid initialization of reference of type ‘char&’ from expression of type ‘const char’ ,这个error里面const char是怎么来的 ?
class TextBlock {
public:
...
const char& operator[] (std::size_t position) const
{return text[position];}
char& operator[] (std::size_t position)
{return text[position];}
private:
std::string text;
}
TextBlock tb("Hello");
std::cout << tb[0];
const TextBlock ctb("World");
std::cout << ctb[0];
...全文
相关推荐
MoreEffective C++
经典MoreEffectC++,c++必修课程
c/c++参考手册,帮助工具
c/c++的开发手册,打开直接使用,查找方便,是中文的,便于理解。
Effective C++.rar
Effective C++ & More effective C++ 英文版 Scott Meyers
More Effective c++中文版和Effective c++中文版英文版
More Effective c++中文版和Effective c++中文版英文版
Effective_C++_3rd_Edition.pdf 英文原版
Effective_C++_3rd_Edition 很棒的C++进阶书 如果能够全部都懂看完 肯定会在语言学习的基础上得到很大的提升


