Question 10: Given the following program snippet, what can we conclude about the use of dynamic_cast in C++?

来源:互联网 发布:yy老虎机源码 编辑:程序博客网 时间:2024/06/05 02:19

 

    A. The dynamic_cast ought to be a reinterpret_cast since the concrete type is unknown.

    B. The dynamic_cast is unnecessary since we know that the concrete type returned by IWidgetSelector::Selection() must be a MyItem object.

    C. The dynamic_cast is redundant, the programmer can invoke Activate directly, e.g. ws->Selection()->Activate();

    D. The dynamic_cast is necessary since we cannot know for certain what concrete type is returned by IWidgetSelector::Selection().

    E. A polymorphic_cast should be used in place of the dynamic_cast.

 

D

原创粉丝点击