Part4. (one) derived class and its object

Source: Internet
Author: User
1. The derived new class has the following features (mainly the first two points ):

1.A derived class is a continuation of a base class definition.---Any member of the base class can be implicitly contained in the derived class.

2.A derived class is an extension of the base class definition.---You can redefine a new member in a derived class (in the "part5" section, you can also see that the function of the base class member function can be changed or expanded in the derived class ).

3.A derived class can be a combination of base classes.---A derived class can be derived from multiple base classes. A derived class is a combination of attributes and behaviors of all base classes.

Summary:Accept all or part of data or functions (actions, Operations) from one or more previously defined classes (called direct base classes ), in addition, the original members are redefined and new members are added, so a new low-level class (called a direct derived class) is formed ). The derived class can be used as the direct base class of the lower-level derived class.

 

In this way, the hierarchy of classes is established)

AvailableDirected Acyclic Graph(Directed acyclic graph, dag)Indicates the inheritance relationship.

2. Note

 

1. Non-static data is stored in the memory stack space

2. UseNewDynamically allocated data is stored in the memory heap space and

3. static data and global variables are stored in the memory data space,

These three types of data are never stored in the same memory space.

The object of the base class and the derived class is not an object.

 

 

3. The derived class object is assigned a value to the base class object, but this is not the case ., You can assign a value to "X1" from the right to the left, but this is not the case.

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.