[英]Strange error c2660 “function does not take 1 arguments”
My base class has this function 我的基类有这个功能
LRESULT CBaseClass::OnTestFunction(WPARAM id, LPARAM=0)
{
...
}
When the derived class calls this function 当派生类调用此函数时
OnTestFunction(nId);
I get an error C2660 : "function does not take 1 arguments". 我得到一个错误C2660:“函数不带1个参数”。
Why is that ? 这是为什么 ?
You need to put the default value in the class definition in the header file. 您需要将默认值放在头文件的类定义中。
class CBaseClass {
....
LRESULT OnTestFunction(WPARAM id, LPARAM=0);
....
};
The default value should be in the class definition: 默认值应该在类定义中:
class CBaseClass {
LRESULT OnTestFunction(WPARAM id, LPARAM=0);
};
so that the derived class can see that signature and the default value. 这样派生类就可以看到该签名和默认值。
Shouldn't be there a name of the parameter in the signature? 签名中不应该有参数名称吗? Like:
喜欢:
LRESULT CBaseClass::OnTestFunction(WPARAM id, LPARAM optional = 0)
{
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.