|
-
October 4th, 2002, 06:43 AM
#1
Casting angst (makes me feel like a newbie)
Hello guys,
Can anyone tell me a safe, nice way to cast between an integral type and a pointer to an object? And vice-versa? I want to use std C++.
eg class CMyThing { ..... };
int main()
{
CMyThing *pObj;
float f;
pObj = some_cast<????>( f );
}
Please dont comment on the why's of this type of operation. I HAVE to do it to work with my current projects legacy code. Its not my fault,honest But I would like to rewrite the old casts that were there to use the correct relevant casts. I had understood reinterpret_cast<> to allow casting arbitrarily, but three compilers I have tried refused to cast a float to a class pointer.
Thanks for all help.
- solosnake
Last edited by solosnake; October 4th, 2002 at 06:47 AM.
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
|