Up shape (upcast)

Source: Internet
Author: User

In simple words, the upward shape refers to viewing the subclass object as a parent class object. Let's take a look at it as follows:

Set: Student inherited from person
Then:
Student person
Student * person *
Student & person &

Internal principle:
A subclass object has a majority of members of a parent class object, except the Private Members of the parent class.
For example, if we say that Zhang San is a student, then we can regard Zhang San as a Chinese student. we can treat the sub-class Object Zhang San as the parent class Object of the Chinese people, which forms an upward shape. However, you can't say that Zhang San is a Chinese, but must he be a student? Obviously not necessarily.

Class person {};
Class student: public person {};

Person Chinese;
Student zhangsan;

Student * Stu = & Chinese;
Student & stud = Stu;

 

Up shape (upcast)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.