A dynamic_cast can cast from a polymorphic virtual base class to a derived class or a sibling class. The dynamic_cast requires a polymorphic operand because there is no information stroed in a nonpolymorphic object that can be used to find the objects for which it represents a base. run time check is performed.
The static_cast operator converts between related types such as one pointer type to another in the same class hierachy,an enumeration to an integral type, or a floating-point type to an integral type. compile time check is performed.

解决方案 »

  1.   

    dynamic_cast   Used for conversion of polymorphic types.
    static_cast   Used for conversion of nonpolymorphic types.
    const_cast   Used to remove the const, volatile, and __unaligned attributes.
                                 -------------from MSDN.
      

  2.   

    what mean is "polymorphic"?
    thanks!!
      

  3.   

    就是有virtual function的class
      

  4.   

    i see!!
    thank masterz()
    can you give me some examples??