C + +: Basic Object-oriented features

Source: Internet
Author: User

The object-oriented method first makes reasonable stratification of the requirements, then constructs the relatively independent business module, finally through the integration each module, achieves the high cohesion, the low coupling effect, thus satisfies the customer request. Specifically, there are three basic characteristics: encapsulation, inheritance, and polymorphism.

Encapsulation: Abstract objective things into classes, and each class protects its own data and methods. Classes can put their own data and methods to allow only trusted classes or objects to operate, to the untrusted information hiding. C + + class is a kind of encapsulation means, the process of using class to describe objective things is encapsulation, which is essentially an abstraction of objective things ...

Inheritance can use all the functionality of an existing class without rewriting the original class, which is intended for code reuse and support polymorphism. It generally has 3 forms: implementation of inheritance, visual inheritance, interface inheritance. Where inheritance is not implemented is the ability to use the properties and methods of the base class without additional coding, visual inheritance refers to the appearance and implementation code of the subform using the parent form, and interface inheritance uses only properties and methods to implement a lag to the implementation of the subclass. The first two (class inheritance) and the latter (object combination-"interface inheritance" and "pure virtual function") Form the two methods of functional reuse. A new class created through inheritance is called a derived class or subclass, and the inherited class is called the parent class, the base class, or the superclass, and the inherited process is from general to special (specific).

Polymorphism means that the same entity has multiple forms at the same time. It is mainly embodied in the inheritance of the class, it is the parent object set is called and one or more of its value object is equal to the technology, after the assignment, the parent can be based on the current assignment of the value of the object's attributes in different ways to operate. Simply put, a pointer to the parent class type is allowed to assign a pointer to the child class type. Compile-time polymorphism is static polymorphism, which can be used to determine the form of an object at compile time.

C + +: Basic Object-oriented features

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.