关于拷贝构造函数, 小人有一事不明
class A {
public:
A(const A& other);
A();
void foo() {}
};
A::A(const A& other) {
other.foo(); // <<-这里编译通不过.
}
A::A() {
}
int main() {
A a;
A b(a);
return 0;
}
gcc提示
ccont.cpp:12: passing `const A' as `this' argument of `void A::foo()' discards qualifiers
vc下也有类似的提示
谢谢