引用抽象类 [英] reference to abstract class

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

问题描述

当有一个抽象类的引用时,是什么意思?
我在代码中找到它,我不能低估它。

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中的接口的指针,使用语法,在引用类上调用virtual方法。

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屋!

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