Performance penalty for working with interfaces in C++?

前端 未结 16 1812
隐瞒了意图╮
隐瞒了意图╮ 2020-12-02 11:21

Is there a runtime performance penalty when using interfaces (abstract base classes) in C++?

16条回答
  •  悲&欢浪女
    2020-12-02 11:55

    As for any class that contains a virtual function, a vtable is used. Obviously, invoking a method through a dispatching mechanism like a vtable is slower than a direct call, but in most cases you can live with that.

提交回复
热议问题