Just like learning the C language, I must first introduce C++ to you to see what the first simple C++ program looks like. To get a preliminary understanding of C++, please look at the following code:
#include<iostream>usingnamespacestd;intmain(){cout<<Nicetomeetyou!<<endl;return0;}
The effect of executing this program is to print the words Nice to meet you! on the screen.
Students who have studied C should have a clear sense of contrast, that is, the header files are different, the output statements are different, and there is an additional sentence to declare the namespace , but the rest has not changed.
Let me give you a simple anatomy:
First of all, in the first line of the program, the file contains the iostream standard library .
The second line declares the use of a namespace called std .
From the third to seventh lines, a C++ program has one and only one main function body . The cout<<Nice to meet you!<<endl; in the curly braces means like printing a sentence on the screen.
Nicetomeetyou!
Okay, now everyone has a simple understanding of it. You may have other confusions, but please don’t worry. Although the sparrow is small and has all the internal organs, even a very simple program also contains a lot of knowledge. In order to make the entry smooth. , we will try to learn along a main line, and the detailed knowledge will be expanded on in detail later.
After a little understanding, please type the code yourself, run it and confirm the results. You can try to modify the output content by yourself, try to print other content, symbols, patterns, etc., and complete the 1001 questions in the training field using C++ language.