@tbscope: You reversed the casts

static_cast is similar to the C style cast and can be applied to just about anything. static_cast would be used when you are certain of the types in question.

dynamic_cast can only be used with pointers and references. On failure to cast, a null pointer is returned. dynamic_cast is generally used when resolving pointers to classes used in inheritance where you want to make sure the pointer you are casting is of the expected type.