Hi,

I'm getting a bit confused while looking at static_cast and dynamic_cast while using references and pointers. I could really do with an idiots guide with plenty of examples to clear things up.

I understand that:

- static_cast has no RTTI checking (and so does not have the associated overhead)

- dynamic_cast uses RTTI checking and so is safer, although this does incur an overhead at runtime

- dynamic_cast can only be used with pointers and references

Is there anything important I'm missing when comparing static vs dynamic casts?


I understand what pointers and references are but could do with some clarification on the following points:


Can you cast from a pointer to a reference?

Can you cast from a reference to a pointer?

Can you cast from an object to a pointer?

Can you cast from an object to a reference?


Is the main use of dynamic_cast then to cast base class pointers/references to derived class pointers/references and vice versa?



Any help would be appreciated!

Cheers!