2

我的基类有这个功能

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

当派生类调用该函数时

OnTestFunction(nId);

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

这是为什么 ?

4

3 回答 3

6

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

class CBaseClass {
    ....
    LRESULT OnTestFunction(WPARAM id, LPARAM=0);
    ....
};
于 2010-12-16T12:47:57.617 回答
4

默认值应该在类定义中:

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

以便派生类可以看到该签名和默认值。

于 2010-12-16T12:48:20.850 回答
0

签名中不应该有参数的名称吗?像:

LRESULT CBaseClass::OnTestFunction(WPARAM id, LPARAM optional = 0)
{
   ...
}
于 2010-12-16T12:45:56.530 回答