错误 C2660:'MouseListener::MousePressed':函数不接受 4 个参数
error C2660: 'MouseListener::MousePressed' : function does not take 4 arguments
im在C 伪图形按钮上工作。我使用观察者模式。
in button.cpp:
void Button::notify()
{
for (int iterator = 0; iterator < listeners.size(); iterator++)
{
listeners[iterator]->MousePressed(*this, x, y, isLeft);
}
}
您可以看到Mousepressed功能会收到4个参数,但我得到:
函数不接受4个参数
in button.h:
struct MouseListener
{
virtual void MousePressed(Button &b, int x, int y, bool isLeft) = 0;
};
class Button : public Label
{
public:
vector <MouseListener*> listeners;
.
.
.
主要:
struct MyListener : public MouseListener
{
MyListener(iControl &c) : _c(c) { }
void MousePressed(Button &b, int x, int y, bool isLeft)
{
_c.setForeground(Color::Red);
}
private:
iControl &_c;
};
int main(VOID)
{
错误:
错误2错误c2061:语法错误:标识符'按钮'c: users gonen gonen unitedproj unitedproj button.h 14 1 unitedproj
错误4错误c2061:语法错误:标识符'按钮'c: users gonen gonen unitedproj unitedproj button.h 14 1 unitedproj
错误5错误C2660:'Mouselistener :: Mousepressed':function不接受4个参数C: Users Gonen Gonen United Proj UnitedProj United Proj button.cpp 24 1 UnitedProj >
当前两个用于主张时,最后一个是在button.cpp中使用函数。帮助?当我用鼠标光标站立在button中的函数上时。cpp我得到:
void mouselistener :: mousepressed(button&amp; b,int x,int y,bool isleft)
我只需要它来工作,以便我可以继续前进,让小组成员使用他们实现的控件中的按钮...然后继续进行下一个我需要做的: - (
编辑:谢谢您的快速答案。我试图做你问的事情。现在我得到:
*错误3错误lnk2019:函数中引用的未解决的外部符号main main c: users gonen gonen gonen unitedproj unitedproj msvcrtd.lib(crtexe.obj)
Button
在声明MousePressed
的点未声明,因此不能使用它。我建议您应该使用远期声明。
class Button; // add this line
struct MouseListener
{
virtual void MousePressed(Button &b, int x, int y, bool isLeft) = 0;
};
class Button : public Label
{
public:
vector <MouseListener*> listeners;
.
.
.
- 函数不接受 X 参数,函数使用默认参数
- 为什么不接受具有默认分配参数的函数作为 0-arg 生成器?
- 函数不接受 C++ 参数
- SQLHANDLE-Parameters:函数不接受x个参数(但实际上确实如此)
- 函数不接受 1 个参数
- 为什么析构函数不接受C++中的参数?
- 为什么C++可变参数模板不接受 iostream 值作为参数?
- C++:将引用作为参数传递,但该函数不接受引用作为参数
- 我的构造函数方法不接受参数(DirectX / Windows)
- 可变参数模板化构造函数不接受 x 参数
- 为什么 std::is_invocable 不接受非类型模板参数
- 错误 C2660:'MouseListener::MousePressed':函数不接受 4 个参数
- 不接受静态成员函数作为 constexpr 参数
- 方法指针映射,编译器说他们不接受任何参数
- GCC 不接受默认模板参数中的包扩展
- 为什么Clang和VS2013接受移动大括号初始化的默认参数,而不接受GCC 4.8或4.9
- C++ 中的特征库给出错误 C2660:"特征::矩阵基<Derived>::特征值":函数不接受 2 个参数
- strtrok_s函数不接受2个参数
- 函数不接受一个参数
- 带有 const 参数的方法不接受非 const 参数