Why is dynamic_cast evil or not ? Should I use dynamic_cast in this case?

前端 未结 3 1652
小鲜肉
小鲜肉 2021-01-12 06:20

Some say the use of dynamic_cast often means bad design and dynamic_cast can be replaced by virtual functions

  1. why is the use of dynamic_cast consi
3条回答
  •  粉色の甜心
    2021-01-12 06:27

    When you use downcasting, dynamic_cast is good, because it restricts you to downcast to irrelevant type. Please refer this.

提交回复
热议问题