关闭

Superclass variable reference with subclass object

481人阅读 评论(0) 收藏 举报

A reference variable of a superclass can be assigned  a reference to any subclass derived from that superclass. You will find this aspect of inheritance quite useful in a variety of situations.

And it is important to understand that it is the type of the reference variable --- not the type of the object that it refers to----that determines what members can be accessed. That is, when a reference to a subclass object is assigned to a superclass reference variable, you will have access only to those parts of the object defined by the superclass.

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:8091次
    • 积分:191
    • 等级:
    • 排名:千里之外
    • 原创:8篇
    • 转载:3篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档