High quality programming guide-C/C ++ chapter 12th C ++ Object-Oriented Programming Method Overview

Source: Internet
Author: User

Chapter 2 C ++ object-orientedProgramDesign method Overview
Encapsulation, inheritance, combination, virtual functions, abstract base classes, dynamic binding, and polymorphism are important concepts in object-oriented programming.
12.1 introduction to object-oriented
12.2 Object Concept
12.3 Information Hiding and class Encapsulation
The most fundamental change of C ++ to C is to put the function into the structure, resulting in a C ++ class. The most taboo for learning C ++ classes is to treat classes as hot pots and throw everything in them.
Inheritance of class 12.4 (is-a-kind-)
For C ++ programs, it is easier to design isolated classes. What is more difficult is to correctly design the base classes and Their Derived classes.
Inheritance is useful and easy to use, but it must be prevented from abuse!
Is-a-part-)
One principle of programming is to prioritize combination (Delegation) rather than inheritance.
12.6 Dynamic Features
In most cases, the functions of a program are determined during compilation, which is called static features. If the function of a program is determined at the runtime, it is called a dynamic feature.
Abstract base class: class with pure virtual functions.
Virtual void draw (void) = 0; // pure virtual function
Explanation of pure virtual functions: we know that,The function name is the function address. initializing a function to 0 means that the function address will be 0, which means that the compiler should not compile the function, this prevents class instantiation.
12.7 C ++ Object Model
The object itself contains only data! Any member function does not belong to any object. The relationship between a non-static member function and an object is bound, and the bound intermediary is the this pointer.

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.