简体   繁体   English

奇怪的错误c2660“函数不带1个参数”

[英]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.

相关问题 C ++错误C2660:函数没有3个参数 - C++ Error C2660: Function does not take 3 arguments 错误C2660:函数没有2个参数C ++ - Error C2660: function does not take 2 arguments C++ 错误C2660:&#39;Aba :: f&#39;:函数未使用0个参数 - error C2660: 'Aba::f' : function does not take 0 arguments 错误C2660:&#39;MouseListener :: MousePressed&#39;:函数未采用4个参数 - error C2660: 'MouseListener::MousePressed' : function does not take 4 arguments 简短版本:错误14错误C2660:“ Player :: addSpell”:函数未采用1个参数 - Short version: Error 14 error C2660: 'Player::addSpell' : function does not take 1 arguments 错误 C2660: 'std::allocator<char> ::allocate': function 不占用 2 arguments</char> - error C2660: 'std::allocator<char>::allocate': function does not take 2 arguments C ++中的特征库给出错误C2660:&#39;Eigen :: MatrixBase <Derived> :: eigenvalues&#39;:函数不带2个参数 - eigen library in C++ gives error C2660: 'Eigen::MatrixBase<Derived>::eigenvalues' : function does not take 2 arguments 如何解决“C2660 &#39;SWidget::Construct&#39;:函数不接受 1 个参数”? - How to resolve "C2660 'SWidget::Construct': function does not take 1 arguments"? 调用可变参数模板函数会在Visual Studio 2015中给出错误C2660 - Calling a variadic template function gives error C2660 in Visual Studio 2015 错误C2660:隐藏派生类中的方法 - error C2660 : Hiding methods in a derived class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM