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

发布于 2024-10-08 09:54:03 字数 225 浏览 0 评论 0原文

我的基类有这个函数

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

当派生类调用这个函数时,

OnTestFunction(nId);

我收到错误 C2660:“函数不接受 1 个参数”。

这是为什么 ?

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".

Why is that ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

画尸师 2024-10-15 09:54:03

您需要将默认值放在头文件中的类定义中。

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

You need to put the default value in the class definition in the header file.

class CBaseClass {
    ....
    LRESULT OnTestFunction(WPARAM id, LPARAM=0);
    ....
};
森林很绿却致人迷途 2024-10-15 09:54:03

默认值应该在类定义中:

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.

无妨# 2024-10-15 09:54:03

签名中不应该有参数名称吗?喜欢:

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

Shouldn't be there a name of the parameter in the signature? Like:

LRESULT CBaseClass::OnTestFunction(WPARAM id, LPARAM optional = 0)
{
   ...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文