' : overloaded function differs only by return type from 'char &MyString::operator [](int)' error C2556: 'const char &MyString::operator [](int)' : overloaded function differs only by return type from 'char &MyString::operator [](int)'](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
char & operator[](int i);
const char & operator[](int i);/*const char & operator(int i);*/
编译出错:
error C2556: 'const char &MyString::operator [](int)' : overloaded function differs only by return type from 'char &MyString::operator [](int)'
修改:
char & operator[](int i);
const char & operator[](int i) const;/*const char & operator(int i);*/
就可以了。
const char & operator[](int i);/*const char & operator(int i);*/
编译出错:
error C2556: 'const char &MyString::operator [](int)' : overloaded function differs only by return type from 'char &MyString::operator [](int)'
修改:
char & operator[](int i);
const char & operator[](int i) const;/*const char & operator(int i);*/
就可以了。