|
-
Jun 6th, 2002, 01:50 PM
#1
Thread Starter
Fanatic Member
casting - HARD
how can i cast a class i made into a void* and back again?
The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.
-
Jun 6th, 2002, 02:20 PM
#2
Monday Morning Lunatic
Why do you want to? You very rarely need to cast a pointer to a void*.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 6th, 2002, 03:10 PM
#3
Thread Starter
Fanatic Member
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)
The human brain cannot hold all of the knowledge that exists in this world, but it can hold pointers to that knowledge.
-
Jun 6th, 2002, 03:12 PM
#4
Monday Morning Lunatic
_beginthread[ex]?
In that case just something like:
Code:
... threadproc(void *param) {
myclass *mc = dynamic_cast<myclass*>(param);
}
// ...
myclass mc;
_beginthread(..., &mc, ...);
Can't remember any of the threading details right now
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 6th, 2002, 04:12 PM
#5
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Jun 6th, 2002, 04:31 PM
#6
Monday Morning Lunatic
You're right...I'm just too used to using dynamic_cast
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|