How come the compiler won't let me cast my DIMOUSESTAT to a void

Started by
1 comment, last by dapeos 20 years ago
Please help DIMOUSESTATE MouseState; pMouse->GetDeviceState(sizeof(DIMOUSESTATE),(LPVOID) MouseState); what is wrong with this, everybook I have shows it this way here is the error: C:\visualStudioProjects\templates\cDInput.cpp(53) : error C2440: ''type cast'' : cannot convert from ''struct _DIMOUSESTATE'' to ''void *'' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called Thanks in advance for your help -Dapeos
Advertisement
try this:

pouse->GetDeviceState(sizeof(DIMOUSESTATE),(LPVOID) &MouseState);

you can't convert a non-pointer to a pointer. so put the little & thingy in front of your MouseState var like above and all should be fine. that gets the memory address of the MouseState var and casts that properly to a void*.

-me

[edited by - Palidine on March 28, 2004 3:27:20 PM]
Thanks so much I should have know that but coming from java a few things are different.
thanks again

This topic is closed to new replies.

Advertisement