关于类成员函数
- C/C++ code
class VAC{public: int f() const { return 3; } int f() { return 5; } //这不属于函数重载 为什么不出错。 };[解决办法]
const函数也是函数重载的一种方式。
[解决办法]
其实就是对类成员函数有一个隐藏的this指针这个事实不清楚才有这种疑惑的,假如我们不隐藏this,函数写出这样,你还有疑惑么?
- C/C++ code
class VAC{public: int f(const VAC * this) { return 3; } int f(VAS * this) { return 5; } };