c++ 中继承 (is-a) 与聚合 (has-a) 的性能影响

发布于 2024-12-25 23:39:52 字数 53 浏览 3 评论 0原文

一个简单的问题 - 使用聚合堆栈时,性能如何影响额外的调用,而不是继承和虚拟方法的性能影响?

A simple question - how does the performance impact the extra calls when using aggregation stack against the performance impact from inheritance and virtual methods?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜味超标? 2025-01-01 23:39:52

与任何其他静态解析的函数调用相比,虚拟主义有一点运行时开销,但这种开销是否足够大只能通过分析来确定。

这个 我最近的回答更详细地解释了这一点。

Virtualism has a little runtime overhead compared to any other statically resolved function calls but if this overhead is big enough can only be determined through profiling.

This recent answer of mine explains this in more detail.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文