#include <iostream>
class A {
public:
void foo() const {
std::cout << "const version of foo" << std::endl;
}
void foo() {
std::cout << "none const version of foo" << std::endl;
}
};
int main()
{
A a;
const A ac;
a.foo();
ac.foo();
}
上面的代码无法编译,谁能告诉我为什么?