Generic C++/Torque pointer witchcraft question
by Gary "ChunkyKs" Briggs · in Torque Game Engine · 08/24/2006 (4:15 pm) · 3 replies
I'm not really much of a C++ guru, so this is probably a dumb question. But: Poking through code, I see this used everywhere:
That whole dynamic_cast-angle-brackets thing versus the normal cast that I'm familiar with. What's the difference?
Gary (-;
mDataBlock = dynamic_cast<JMTorqueData*>(dptr);Why is this better, worse, different from, or the same as:
mDatablock = (JMTorqueData *)dptr;
That whole dynamic_cast-angle-brackets thing versus the normal cast that I'm familiar with. What's the difference?
Gary (-;
#2
but the short answer is that the first example will only succeed if dptr does in fact point to a JMTorqueData,
whereas the second example succeeds even when it shouldn't.
if you *know* the pointer points to an object of the correct type,
then using the second approach is slightly faster.
08/24/2006 (4:51 pm)
Definitely read Dreamer's link,but the short answer is that the first example will only succeed if dptr does in fact point to a JMTorqueData,
whereas the second example succeeds even when it shouldn't.
if you *know* the pointer points to an object of the correct type,
then using the second approach is slightly faster.
Torque Owner Dreamer
Default Studio Name