抽象与规范类继承的性能 [英] Abstract vs Normal class inheritance performance

查看:125
本文介绍了抽象与规范类继承的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当你从一个类和实例派生子类,运行时也实例超类的吧?

When you derive from a class and instance the subclass, the runtime also instances the super class, right?

由于抽象类不能被实例化,都被当一个子类实例化运行时产生的?

Since abstract classes can't be instanced, are they not created by the runtime when a subclass is instanced?

如果是这样,那么抽象类的继承会比正常的类的实例更快?

If so, then abstract class inheritance would be faster than normal class instance?

推荐答案

运行时从不创建基类和派生类的不同实例 - 它只是派生类实例的也有的全部变量等的基类,并运行基类构造函数初始化过程中。有没有什么区别正常的基类和抽象基类之间的位置。

The runtime never creates separate instances of the base class and the derived class - it's just that the derived class instance also has all the variables etc of the base class, and runs the base class constructor as part of initialization. There's no difference here between "normal" base classes and abstract base classes.

这篇关于抽象与规范类继承的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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