Performance penalty for working with interfaces in C++?

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

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

16条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 11:37

    Using abstract base classes in C++ generally mandates the use of a virtual function table, all your interface calls are going to be looked up through that table. The cost is tiny compared to a raw function call, so be sure that you need to be going faster than that before worrying about it.

提交回复
热议问题