Click to See Complete Forum and Search --> : casting - HARD
DNA7433
Jun 6th, 2002, 01:50 PM
how can i cast a class i made into a void* and back again?
parksie
Jun 6th, 2002, 02:20 PM
Why do you want to? You very rarely need to cast a pointer to a void*.
DNA7433
Jun 6th, 2002, 03:10 PM
um, actually its this other guy who wants to know, i think he's trying to create a new thread but i don't remember which API it was he was using, i don't think it was CreateThread(Ex)
parksie
Jun 6th, 2002, 03:12 PM
_beginthread[ex]?
In that case just something like:
... threadproc(void *param) {
myclass *mc = dynamic_cast<myclass*>(param);
}
// ...
myclass mc;
_beginthread(..., &mc, ...);Can't remember any of the threading details right now :p
CornedBee
Jun 6th, 2002, 04:12 PM
I think you need a reinterpret_cast, dynamic_cast won't work (works only for casting among class hierarchies with RTTI enabled). I think static_cast for something* to void* and reinterpret_cast for void* to something*.
Clashes of good C++ and C APIs always favor C.
parksie
Jun 6th, 2002, 04:31 PM
You're right...I'm just too used to using dynamic_cast :D
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.