Why should virtual functions not be used excessively?

前端 未结 10 2063
再見小時候
再見小時候 2021-02-19 13:16

I just read that we should not use virtual function excessively. People felt that less virtual functions tends to have fewer bugs and reduces maintenance.

What kind of b

10条回答
  •  误落风尘
    2021-02-19 13:29

    The virtual table gets created for each class, having virtual functions or deriving from a class containing virtual functions. This consumes more than usual space.

    The compiler needs to silently insert extra code for ensuring that the late binding takes place instead of the early binding. This consumes more than usual time.

提交回复
热议问题