How would I cast this with reinterpret_cast? I tried the following without success;Code:return ((Foo*)bar)->func();
Code:return reinterpret_cast<Foo*>(bar)->func();
How would I cast this with reinterpret_cast? I tried the following without success;Code:return ((Foo*)bar)->func();
Code:return reinterpret_cast<Foo*>(bar)->func();
I'd say that that depends on what is the type of bar, and how it is related to Foo.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
And what does the extra parentheses do in the first snippet?
So that the cast applies to bar, not bar->func().Originally Posted by Tux0r
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Ok
I'm gonna try solving the problem again...
edit: Didn't work so I just put a static_cast there... I still don't get why reinterpret_cast didn't work though.
Last edited by Tux0r; 07-21-2009 at 04:28 AM.
Maybe you need dynamic_cast or const_cast? Without knowing what the types are and how they're related, it's hard to say.
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010