Thank you all for the tips.
@Cubbi. It turned out to be as you said.
I didn't think there would be a scope confusion issue but there is!
Changing to:
const int& dragDrop::mseX = ::mseX;
worked.
I then changed the member name to r_mseX and now:
const int& dragDrop::r_mseX = mseX;
works fine too.
@webJose. The const keyword seems to be ok to use.
I am used to using const&'s in the context of class member function arguments such as:
obj(const obj& r_obj);// copy ctor
and
obj operator+(const obj& r_obj)const;// operator overloading
where it allows access to the member values.
I'm already doing as you suggested by using a
static int
in my button class.
The problem is that this needs to be updated when the mouse moves. Now when the mouse moves I would have:
1 2 3 4 5
|
case WM_MOUSEMOVE:
button::mseX = LOWORD (lParam);
button::mseY = HIWORD (lParam);
dragDrop::mseX = LOWORD (lParam);
dragDrop::mseY = HIWORD (lParam);
|
I want to limit this before it gets out of hand! I'd like to update one set of global variables and pass out references to them.
@ne555. I looked up the
volatile
keyword since I've heard of it but never used it.
MSDN wrote: |
---|
The volatile keyword is a type qualifier used to declare that an object can be modified in the program by something such as the operating system, the hardware, or a concurrently executing thread. |
I didn't see how any of those conditions applied. Thanks though!