14th class Advanced Object oriented (bottom)

Source: Internet
Author: User

1. Basic relationships between classes

(1) Inheritance

① has an inheritance relationship between classes that are broken down from existing classes and the original classes (IS-A)

② inherited classes (subclasses) have all the properties and behaviors of the original class (The parent Class)

(2) Combination

① the existence of some classes must depend on other classes, a relationship called a combination

The class of a ② group is made up of other classes on a certain part .

2. representation of Classes

Notation for the "programming Experiment" class

#include <stdio.h>structbiology{BOOLLiving//Life};structanimal:biology{BOOLmovable;//can be moved    voidFindfood () {};//Find Food};structplant:biology{BOOLgrowable;//can grow};structbeast:animal{voidSleep () {};//Sleep};structhuman:animal{voidSleep () {};//Sleep    voidWork () {};//Labor};intMain () {return 0;}

3. Summary

(1) There can be an inheritance or composition relationship between classes

(2) Inheritance relations The Neutron class has all the properties and behaviors of the parent class

(3) A combinatorial relationship is the relationship between the whole and the part of a class

(4) The relationship between classes and classes can be represented in different ways

(5) The compiler has specific requirements for the representation of the class

14th class Advanced Object oriented (bottom)

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.