C + + Self-study-preparatory knowledge

Source: Internet
Author: User

Introduction to C + +

C + + is supported by the addition of object-oriented programming and generic programming, which makes C + + three ways of programming: process-oriented, object-oriented, generic programming. Before you learn C + +, it's best to master the basics of C and OOP programming.

Process-oriented, object-oriented, generic programming

  1. Process oriented: Generally speaking, there are 2 concepts of computer language processing-data and algorithms. The data is the information that the program uses and processes, and the algorithm is the method that the program uses, for example: I want to fry a chili to fry the meat, edible oil, fresh meat, chili pepper ... These are data, cut meat-burning oil-stir fry with meat .... These are called algorithms. C language in order to solve the problem of branch statements, so that it has the ability to process judgment, you can use such as "if Else" "for" and "while case" and other process processing language, this method is called structured programming. Another principle is the top-down principle, the top-down design, in the C language, the idea is to break up large tasks into many small tasks, and if these small tasks are still too large, they will be subdivided into smaller tasks until the program is divided into small, manageable modules, such as: I'm going to tidy the study, Then divided into tidy bookcases, tables, chairs, and the bookcase can be divided into the left, the middle, the right three bookcases, fine can be divided into the left of the first, the second .... The C language encourages programmers to develop program units (that is, functions) to represent individual task modules. Structured programming reflects process-oriented programming ideas and constructs a program based on the actions performed.
  2. Object-oriented: for process-oriented programming, its advantage is to improve the program's clarity, reliability, and ease of maintenance, but the use of this idea in the writing of large programs is somewhat inadequate, in order to deal with this problem, OOP provides a new method, The process-oriented approach is the algorithm (that is, cutting meat-burning oil-put meat stir fry ... , while the object-oriented focus is on data (i.e. edible oil, chili, fresh meat ...). ), it is not a process-oriented approach that satisfies the problem of structured programming, but rather enables the language to meet the requirements of the problem. In C + +, "class" is a specification that describes the new data format, "Object" is a specific data structure constructed according to this specification, such as: class can describe a dish of raw materials (item name, category, source, price ...) ), while the object is a specific data format with data (pork, meat, supermarket, $ ...). The popular understanding class is the template for the object, which defines the operational capabilities or attributes of the object to which it derives. OOP Program design first design class, they accurately express the program to process the data, the class definition describes the operation of each class executable, and then the application of the specification of the class, this from the low-level organization to the High-level organization of programming called DOWN-TOP (bottom-up) programming. Not only does OOP combine data and algorithms into classes, OOP can create reusable code and reduce effort. Information hiding protects private data and avoids illegal access. Polymorphism can create multiple definitions for operators and functions, determine which definition to use through its context, inherit from the old class, and so on ..... Object-oriented programming in the Windows environment, with a large number of simplified classes provided by the vendor, making it easy for developers to use.
  3. Generic programming: This is another programming pattern supported by C + +, the same as OOP, where OOP emphasizes data, while generic programming emphasizes independent of specific data types, and generic programming provides tools for common tasks. C + + has a variety of data types, such as int, long, char ..... And so on, generic programming requires that languages be extended so that you can write only one generic function and use it for a variety of actual types.

C + + Self-study-preparatory knowledge

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.