小编MMM*_*MMM的帖子

Operator []重载写入/读取之间的区别?

我是C++的新手,我很抱歉因为这个问题,但这是一场斗争.如果有人能帮助我区分以下几行,我会很感激.

char& operator [](int);         // write (why with reference?)
char operator [](int) const;    //read (why without a reference?)
char const &operator[](int) const; // what is the difference compared to the previous line?
const char *& operator[] (const int* ); // is this also possible?
Run Code Online (Sandbox Code Playgroud)

c++ pointers reference operator-overloading

5
推荐指数
1
解决办法
521
查看次数

标签 统计

c++ ×1

operator-overloading ×1

pointers ×1

reference ×1