C++中const对象引用的一些限制
先上示例代码:
class Test {
public:
void doConst() const {
//
}
void doNoConst() {
//
}
};
int main(int argc,char **argv){
Test t;
const &ct=t;
//error: passing xxx as 'this' argument of xxx discards qualifiers [-fpermissive]
ct.doNoConst();
//Correct;
c...
leiex.com1 min read