reference to abstract class

前端 未结 4 481
一向
一向 2020-12-05 08:53

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 instantia

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 09:20

    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.

提交回复
热议问题