代码改变世界

error C2556: 'const char &MyString::operator [](int)' : overloaded function differs only by return type from 'char &MyString::operator [](int)'

2014-02-15 20:40  hongjiumu  阅读(643)  评论(9编辑  收藏  举报
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);*/
就可以了。