关于 VC++ vitual, reload 和 derive的一个问题...# Programming - 葵花宝典
o*r
1 楼
以下程序似乎是对的,在Visual Studio 2005里面却报错:
error C2660: 'B::Add' : function does not take 1 arguments
#include
using namespace std;
class A
{
public:
int Add(int X) {return Add(X, 1);};
private:
virtual int Add(int X, int Y) {return X+Y;};
};
class B: public A
{
private:
int Add(int X, int Y) {return X-Y;};
};
int main()
{
B Obj;
cout << Obj.Add(5);
return 0;
}
难道B不能用base clas A的那个public function吗?
用不同函数名就没问题了
#include
using namespac
error C2660: 'B::Add' : function does not take 1 arguments
#include
using namespace std;
class A
{
public:
int Add(int X) {return Add(X, 1);};
private:
virtual int Add(int X, int Y) {return X+Y;};
};
class B: public A
{
private:
int Add(int X, int Y) {return X-Y;};
};
int main()
{
B Obj;
cout << Obj.Add(5);
return 0;
}
难道B不能用base clas A的那个public function吗?
用不同函数名就没问题了
#include
using namespac