C + + Primer Plus "first chapter preparatory Knowledge" "Notes/Insights" "complements"

Source: Internet
Author: User
Tags class definition

1.1 C + + Introduction

C + + blends 3 different ways of programming:

1.C (Procedural language)

2.OOP (Object-oriented language)

3.templata (Generic programming)

1.2 A brief History of C + +

With the development of computer hardware, more and more complicated programs are brought forward, and these programs bring new problems in the management and maintenance of the program. In this context, C language emerged, leading people into the structure of programming era. C generates simple, fast-running programs and provides the ability to handle hardware problems

1.2.1 C language

In order to develop the UNIX operating system, a simple and fast program can be generated, and the hardware can be controlled effectively. The traditional assembly language relies on the internal machine language of the computer, directly manipulating the hardware, so it can only be targeted to specific computer processors. UNIX is designed to work on different computers (or platforms). The compiler translates the high-level language into the internal language of a particular computer. The C language has thus been developed

1.2.2 C Language Programming principles

Two concepts to be processed in computer language--data and algorithms

The data is the information that the program uses and processes, the algorithm is the method which the program uses

  

  

C is a procedural language, emphasizing the algorithmic aspects of programming, conceptually, the process of programming first to determine what the computer should do, and then use the programming language to implement these operations

C language uses structured programming to solve the problem of organization confusion in early programming languages such as FORTRAN and basic

A new principle in C is the top-down design, which breaks down large programs into small, manageable tasks. If one of the tasks is too large, break it down into smaller tasks)

1.2.3 Object-Oriented programming

Unlike OOP, which emphasizes procedural programming of algorithms, OOP emphasizes data. OOP, unlike procedural programming, tries to make the problem satisfy the procedural method of the language, but instead tries to let the language meet the requirements of the problem. The idea is to design a data format that corresponds to the intrinsic nature of the problem.

In C + +, a class is a specification that describes the new data format, which is a specific structure constructed from this specification.

Typically, a class specifies what data can be used to represent an object and what operations can be performed on that data

OOP programming methods first design classes, which accurately represent what the program is dealing with. For example, a drawing program might define a class that represents a rectangle, a line, a circle, a paint brush, or a brush. The class definition describes the actions that can be performed on each class, such as moving a circle or rotating a line. You can then design a program that uses objects of these classes.

The process of processing from low-level organizations (such as classes) to high-level organizations (such as programs) is called bottom-up programming

OOP programming combines data and methods into a class definition. For example, OOP can also help create reusable code. Information hiding can protect data. Polymorphism can create multiple definitions for operators and functions. Inheritance can use the old class to derive a new class

OOP differs from procedural programming in that it does not focus on tasks, but on concepts

The OOP language has a number of useful libraries, and one of the real advantages of C + + is that it is easy to reuse and modify existing, carefully tested code

1.2.4 C + + and generic programming

Generic programming is the same as OOP, even if the technique of reusing code and abstracting common concepts is simpler

OOP emphasizes the data aspect of programming, while generic programming emphasizes being independent of specific data types

OOP is a tool for managing large projects, while generic programming provides tools for performing common tasks, such as sorting

1.2.5 The origins of C + +

C + + is a superset of the C language, which means that any valid C program is a valid. C + + program. There are slight differences between them, but they are insignificant.

The OOP section gives the C + + language The ability to relate the concepts involved in the problem, while part C gives the C + + language the ability to closely connect the hardware

1.3 Portability and standards

 Portability: If you recompile the program without modifying the code, the program will run well, and the program is portable

Two barriers to portability: 1. Hardware-specific programs that are not portable (placing hardware-dependent parts in function modules can minimize portability: this is just a matter of rewriting these modules). 2. Standard issues (establishing a unified C + + standard)

There are some differences between ANSI C and the corresponding C + + rules, but this difference is small. In fact, ANSI C added some features that were first introduced by C + +, such as function prototypes and type qualifier const

1.4 Tips for creating programs

  

C + + Primer Plus "first chapter preparatory Knowledge" "Notes/Insights" "complements"

Related Article

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.