对抽象类的引用 [英] reference to abstract class
本文介绍了对抽象类的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
引用抽象类是什么意思?我在代码中发现了它,我无法理解它.
What does it mean when there is a reference to an abstract class? I found it in code and I can't understant it.
我认为抽象类不能被实例化.怎么给个参考?
I thought that an abstract class can't be instantiated. How can you give it a reference?
推荐答案
对抽象类的引用就像一个指向抽象类的指针:它需要引用抽象类的某个非抽象子类的对象.您可以使用类似的引用来使用 .
语法调用被引用类上的虚拟方法,其方式类似于 Java 中指向接口的指针.
A reference to an abstract class is just like a pointer to an abstract class: it needs to reference an object of some non-abstract subclass of the abstract class. You can use a reference like that to call virtual methods on the referenced class using the .
syntax, in a way similar to a pointer to an interface in Java.
这篇关于对抽象类的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文