c++ - Is Nokia mis-using static_cast? -


I just came in:

Scroll down to the bottom of the page, where you will search < / P>

  QWidget * pw = static_cast & lt; QWidget * & gt; (Guardian);   

The parent is of type: QObject, which is the base class of QWidget, so in this case, isnt: should dynamic_cast be used?

Like:

  QWidget * pw = dynamic_cast & lt; QWidget * & gt; (Original)   

Thanks,

If you know that You are casting from a descendant to an offspring from below (i.e., you know that the object is actually an example of the descendant), then static_cast is completely legal (and more executable).

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -