I have not found a way to initialize a class member successfully inside the constructor, and I cannot understand why.
I have a header file:
#pragma once
struct STATE_MOUSE {
bool moving;
int left_button;
int right_button;
int middle_button;
bool scroll_up;
bool scroll_down;
};
class Message {
private:
static STATE_MOUSE state_mouse;
public:
Message();
~Message();
};
Then I have the source file:
#include "message.hpp"
STATE_MOUSE Message::state_mouse = {false, 0, 0, 0, false, false};
Message::Message() {
}
Message::~Message() {
}
Now about the problem. This seems to work. However, I use to initialize the members inside the constructor, and I have not found a way to do this with this static member of the structure.
The following method does not work, can someone explain why?
state_mouse.moving = false;
source
share