类初始化的性能如何? [英] Classes initialization cubersome in performance?

查看:65
本文介绍了类初始化的性能如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,

因此我将游戏引擎更改为更像C ++的代码,方法是使用主类Windows,引擎的初始化等。但是现在我在使用类中的函数实际创建窗口之前经历了非常长的初始化时间。
srsly花了那么多时间来用C ++初始化一个类>>>我使用自己的编码构造函数,只初始化5个变量(应该花费很长时间)。

so I changed my game engine into a more C++ like code, by using a class for the main windows, initializations for engine etc. But now I experience EXTREMELY long initialization time before my window is actually created with the function in the class. Does it srsly take that much time to initialize a class in C++>>> Im using my own coded constructor, only initializing 5 variables (should take long at all).

BTW,为什么这么多人在C ++中使用Classes?有什么好处????性能或者......

BTW, why do so many people use Classes in C++?? What's the advantage???? Performance or sth??

推荐答案

初始化对象不需要很长时间,你需要时间的是初始化的对象你的构造函数。我建议你测量不同的步骤。也可能是你已经创建了一些尚未需要的对象,如果没有代码本身则需要很难说明。发布构造函数代码可能会有所帮助。

It does not take a long time to initialize an object, what can take time is what you initialize in your constructor. I would suggest that you measure the different steps. It might also be that you already create some objects that are not yet required, hard to tell without the code itself. Posting the constructor code could help.

对于第二个问题,C ++旨在提供额外的灵活性,抽象性和生产力。普通C"可以/将"通常比C ++更快,但更难掌握,特别是如果你瞄准游戏开发......

For your second question, C++ has been designed to allow extra flexibilty, abstraction and productivity. Plain C "can/will" often be faster as C++, but is harder to master, especially if you target game development...


这篇关于类初始化的性能如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆