dynamic_cast and assert

M

m0shbear

Given

#include <cassert>

void f(void *p) {
//...
assert(dynamic_cast<Q*>(p));
//...
}

Would the dynamic_cast comparison method work for runtime testing of a
pointer's expected type without relying on typeid(p).name() ?
Note: this applies to pointers to C types, not just classes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,044
Members
48,769
Latest member
Clifft

Latest Threads

Top