KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In this program I have a void * as a parameter and want to cast it to a specific type. But I don't know which "casting symbol" to use. Both static_cast or reinterpret_cast work. Which one is better? Which one does the Standard C++ recommend? typedef struct { int a; }A, *PA; int foo(void* a) // the real type of a is A* { A* pA = static_cast<A*>(a); // or A* pA = reinterpret_cast<A*>(a);? return pA->a; } Here, is A* pA = static_cast<A*>(a); or A* pA = reinterpret_cast<A*>(a); more proper?
Tags (comma-separated)
Save Edits
Cancel