C++ Tutorial

C++, short for "C Plus Plus". As the name suggests, C++ adds new features on the basis of C language and plays new tricks, so it is called "C Plus Plus", just like the relationship between Win10 and Win7.

The relationship between C++ and C language

Now it seems that although C++ and C language are two independent languages, they have an indistinct relationship.

In the early days, there was no "C++" name, but "C with classes". "C with classes" appeared as an extension and supplement of the C language, it added a lot of new syntax, the purpose is to improve the development efficiency, if you have Java Web development experience, then you can relate them to Servlet and A relational analogy for JSP.

C++ in this period was very rough, only supported simple object-oriented programming, and did not have its own compiler, but through a preprocessor (named cfront), the C++ code was first "translated" into C language code, and then through C The language compiler synthesizes the final program.

With the popularity of C++, its syntax has become more and more powerful, and it has been able to fully support procedural programming, object-oriented programming (OOP) and generic programming. It has almost become an independent language with its own compiler. Way.

It is difficult to say that C++ has a separate compiler, such as the Microsoft compiler (cl.exe) under Windows, the GCC compiler under Linux, the Clang compiler under Mac (already the default compiler for Xcode), and they all support C at the same time language and C++, collectively referred to as the C/C++ compiler. For C language code, they are compiled in the C language way; for C++ code, they are compiled in the C++ way.

On the surface, C and C++ code are compiled using the same compiler, so we said above that "later C++ has its own compilation method", but not "C++ has an independent compiler".

Let's talk about the C++ tutorial

If you write a C++ book for readers without any programming experience, it will be a big task, and the book will be very thick. Even so, it's just grammar.

More importantly, it is difficult for you to absorb all of these knowledge, which will seriously damage your confidence and lose your interest in learning.

Our suggestion

For readers without any programming foundation, we recommend learning from C language first.

Learning to program is a step-by-step process, don't expect to eat a fat man in one bite. To learn C language, one is to learn its syntax, lay a foundation for C++, and at the same time cultivate programming interest, and the other is to learn memory, compilation and linking, and to understand the internal mechanism of the programming language.

When you are familiar with the C language and can write hundreds of lines of code, you will have some concepts about programming. At this time, to understand what C++ has added to the C language, you will stand at a certain height.

C++ supports procedural programming, object-oriented programming, and generic programming, while C language only supports procedural programming. As far as procedural programming is concerned, C++ and C are almost the same, so if you learn C language, you will learn half of C++, and you don't need to start all over again.