what's polymorphic type in C++?

前端 未结 5 1322
猫巷女王i
猫巷女王i 2021-02-01 14:56

I found in one article saying \"static_cast is used for non-polymorphic type casting and dynamic_cast is used for polymorphic type casting\". I understand that int and double ar

5条回答
  •  你的背包
    2021-02-01 15:12

    I think the full phrase is "polymorphic type casting". You are right that static_cast works on types that are not related by inheritance (double - int, etc) and the others answers point out how the casts work.

    I don't think the statement implied the existence of a mythical polymorphic type though - just that static_cast also works on unrelated types. The statement was a little confusing though and it's good to clarify.

提交回复
热议问题