I'm using reinterpret_cast something like this:
void RunThread (void *myself)
{
(reinterpret_cast<MyClass*>(myself))->Method();
}
Inside Method, most of my member variables (all Handles) are null. Could this be because of reinterpret_cast since I know it does not guarantee me the same addresses? Like static_cast would. I know we should be using static_case in this instance, but this issue has got me interested now.
No. reinterpret_cast
doesn't perform any operations on source pointer, just treats its value as another pointer (or integral) type. It could give you wrong result only in case when memory pointed bymyself
does not contain MyClass
(or binary compatible) object.