The concept of modeling language is related to the concept of programming language (must read for beginners)

Source: Internet
Author: User


1. generalization (generalization)

In C + +, the corresponding inheritance, such as B is a generalization, in C + + performance as:

Class B:public a{public  :    B () {}    Virtual ~b () {}}

</pre><pre>
2.implementation (realization)

In C + +, corresponding to the concept of virtual functions, such as B implemented a. is to implement the detailed function (interface) of the virtual function in a, which is represented in C + +:

Class a{    public:a () {}virtual ~a () {}virtual void fun (int x,int y) = 0;};
Class B:public a{public  :        B () {}virtual ~b () {}        virtual void fun (int x,int y);}
3. Association (Associate)is a partnership,if B is associated with a, B knows the properties and methods of a (B can use the properties and methods of a),The parameters of the corresponding method in C + +:
Class B {      public:b () {}virtual ~b () {}void fun (A *m_a);}



4. Aggregation relationship (Aggregation)
is the relationship between the general and the individual. is a United Nations-style organization, which is a kind of weakness including that each individual can exist independently. In C + + the corresponding attribute life cycle of the conceptual aggregation relationship, the individual life cycle is not the overall control.
Class b{public   :      B () {}      Virtual ~b () {}      A *m_a;}


in the detailed implementation. The individual of a is generated outside of B. It is possible to pass an individual in the form of a pointer to B at the appropriate time. 5. Composition relationship (composition)is the relationship between the general and the individual. is a kind of die organization, is a kind of strong including, each individual can not exist independently. In C + +, the life cycle of an individual is dominated by the overall concept of the corresponding attribute life cycle.
Class b{public  :     B () {}     Virtual ~b () {}     A m_a;}


Pointers can also be used in detailed implementations. It's time to be aware that B is in charge of A's life and death.


The concept of modeling language is related to the concept of programming language (must read for beginners)

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.