开发者

Strange error c2660 "function does not take 1 arguments"

开发者 https://www.devze.com 2023-01-30 17:37 出处:网络
My base class has this function LRESULT CBaseClass::OnTestFunction(WPARAM id, LPARAM=0) { ... } Wh开发者_StackOverflow中文版en the derived class calls this function

My base class has this function

LRESULT CBaseClass::OnTestFunction(WPARAM id, LPARAM=0)
{
...
}

Wh开发者_StackOverflow中文版en the derived class calls this function

OnTestFunction(nId);

I get an error C2660 : "function does not take 1 arguments".

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)
{
   ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消