即使我推送对象,队列模板类也始终为空,我也不知道我在做什么错。
我的代码如下:
void Mouse::onMouseMove(int x, int y){
this->x = x;
this->y = y;
MouseEvent me(MouseEvent::EventType::move, x, y);
this->eventBuffer.push(me);}
每当我调用该函数时,它都不会执行任何操作。
当我从中返回某些内容时,该函数似乎可以正常工作了。
这是其他一些代码:
case WM_MOUSEMOVE:
{
int x = GET_X_LPARAM(lParam);
int y = GET_Y_LPARAM(lParam);
mouse.onMouseMove(x, y);
return 0;
}
public:
int onMouseMove(int x, int y);
int getPosX();
int getPosY();
MousePoint getPos();
bool eventBufferEmptry();
MouseEvent readEvent();
private:
std::queue<MouseEvent> eventBuffer;
int x = 0;
int y = 0;
bool Mouse::eventBufferEmptry()
{
return this-eventBuffer.empty();
}
MouseEvent Mouse::readEvent()
{
if (this->eventBuffer.empty())
{
return MouseEvent();
}
else
{
MouseEvent e = this->eventBuffer.front();
this->eventBuffer.pop();
return e;
}
}
答案 0 :(得分:0)
我找到了答案,我已经忘记了>像这样制作指针箭头时-> 相反,我只有-,所以它总是将状态设置为空弹出等,而不是填充它。