solosnake
October 4th, 2002, 06:43 AM
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
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