<分区>
Possible Duplicate:
What is the performance cost of having a virtual method in a C++ class?
界面确实会减慢程序速度吗?我听说是这种情况,因为在运行时,每次使用实现该接口(interface)的对象时,都必须决定实现该对象属于哪个类的接口(interface)。
我对 C++ 的答案特别感兴趣,但也有一般性的答案。如果这是真的,一些数字也会有帮助。
非常感谢!
<分区>
Possible Duplicate:
What is the performance cost of having a virtual method in a C++ class?
界面确实会减慢程序速度吗?我听说是这种情况,因为在运行时,每次使用实现该接口(interface)的对象时,都必须决定实现该对象属于哪个类的接口(interface)。
我对 C++ 的答案特别感兴趣,但也有一般性的答案。如果这是真的,一些数字也会有帮助。
非常感谢!
最佳答案
是的,但如果您需要接口(interface)所需的灵 active ,那么影响不大,当然也不够。 (请记住,如果您大量使用接口(interface),vtables 的相关位将最终进入 L1 或 L2 缓存,因此不会像您担心的那么多。)
关于c++ - 使用接口(interface)会减慢程序速度吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2714144/