The first chapter is preparatory knowledge
1. Introduction to C++
C++ combines three different types of programming:
- C language
Procedural language
- C++ adds class representation on the basis of C language
Object oriented language
- C++ template support
Generic programming
C++ inherits the tradition of efficiency, simplicity, speed, and portability of C.
A Brief History of C++
2.1 C language programming: procedural language
Dennis Ritchie of Bell Labs developed C on the basis of the old language in order to design and develop Unix for versatility and portability.
Assembly language relies on the computer’s internal machine language to operate directly on the hardware.
Data: Information used and processed by a program.
Algorithms: Methods used by a program.
C is a procedural language, emphasizing the algorithmic aspects of programming. A structured approach to programming.
C’s new principle: top down design, ideal: break up large programs into small, manageable tasks.
2.2 Object Oriented Programming
Procedural languages (C) emphasize algorithms, OOP (C++, Java, etc.) emphasize data.
Unlike procedural programming, the idea of OOP is to design data formats that correspond to the nature of the problem. Here are the differences:
Procedural language (let the problem satisfy the language)
OOP programming (let the language do the job)
In C++, a class is a specification that describes a new data format, and an object is a specific data structure constructed according to the class specification.
Class specifies what data can be used to represent an object and what operations can be performed on that data.
The OOP approach to programming is to design classes (which explicitly represent what the program is dealing with), and then design programs that use the objects of the classes.
The process of moving from low-level organization (such as classes) to high-level organization (such as programs) is called bottom-up programming thinking.
Class definition = data + methods
OOP can create reusable code that reduces a lot of work, and information hiding can protect data from inappropriate access.
Different environments (Windows and Macintosh) provide programming libraries that make it easy to reuse and modify existing, carefully tested code.
2.3 C++ and Generic Programming
Generic Programming is another programming pattern supported by C++. With OOP target system.
Term: Generics (referring to the creation of type-independent code).
Differences between OOP and generic programming:
OOP
programme-orienteddata
Aspects,Manage large projects
The toolsGeneric programming
Emphasis onIndependent of a particular data type
To providePerform common tasks (such as sorting data or merging lists)
The tool.
C++ generic programming needs to extend the language so that you can write a single generic (that is, non-type-specific) function and use it for a variety of real types.
3. Portability and standards
C++ is a superset of C. Any valid C program is a valid C++ program.
3.1 Two barriers to portability
- Hardware: Place modules in blocks to minimize portability issues by rewriting modules.
- Language differences: International organizations have defined standards for C, C++99, C++11, C++14, etc.
3.2 Duality of C++
- OOP provides high-level abstraction
- C provides low-level hardware access
👉 C++ can not only abstract through OOP, but also perform the same operations as C for hardware access.
4, program creation skills
4.1 Programming steps
Read “Principles of Compiling” for more details.
4.2 Common compilers
- Linux/UNIX: the GNU GCC/g + +
- Windows: Software IDE
- Mac OS: Xcode comes with g++ and Clang
Making address: https://github.com/SolerHo/cp…