Introduction to c++ Part 1

The steps generally required to write a C++ program are editing, debugging, compiling, and linking.

1 C++ is a compiled language

Only machine instructions (composed of 01) can be run on the computer. Programs written in any other language (including assembly) must be translated into corresponding machine instructions before they can be run. C++ is a compiled language.

There are many compiled languages, and common high-level languages ​​are compiled languages, such as Java, C\C++, C#, etc., which are characterized by a series of processing before running. This process is usually called "compilation". After the compilation is successful, it will Generate the corresponding binary file, which is the executable file (your program).

The corresponding interpreted languages ​​include: Python, JavaScript, HTML, etc., which are characterized by "interpretation" during runtime, that is, each time a language is executed, it is interpreted into the corresponding machine instructions.

As we all know, compiled languages ​​are fast. The fast thing is actually "compile once and run multiple times", while interpreted languages ​​have to be "interpreted" every time they are run, so they are slower. However, the actual development process of interpreted languages ​​is much faster than compiled languages. The reason is also that compiled languages ​​must be compiled before running. When the project is large, compilation can take a lot of time and is not suitable for debugging. In addition, the cost of learning compiled languages ​​​​is and difficulty is greater than the explanatory type.

The operation of a compiled language can usually be divided into several steps, as follows:
(1) Editing, editing code;
(2) Compiling, checking grammatical specifications, and translating source files into machine instructions;
(3) Connecting, combining several compiled Files are combined into one file;
(4) Run, run exe and other programs.
For example, Java's java -c needs to be compiled into a class file first, and then java -jar is connected into one file.
C++ compiles it into an .o file and then connects it into an exe

1.1 Windows platform runs c++

Insert image description here
In vs, we want to output the log and output it to the console at the same time. (1) Then we add the following code to the code: freopen("output.txt", "w", stdout); (2) Processing in the project properties Click the drop-down button on the far right side of the processor definition, select Edit from the drop-down menu, open the settings dialog box for the preprocessor definition, and add _CRT_SECURE_NO_WARNINGS
VS input and output redirection problem_vs redirection input and output_cmsmalldog's blog- CSDN Blog
solves C++error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead.-CSDN Blog

1.2 Linux platform running c++

These steps are basically the same under Linux. The difference is that the final file generated by Linux is not .exe, but .out
Insert image description here

1.3 Clion and MinGW-w64 (compiler) installation tutorial

[1] Detailed steps to download and install MinGW-w64 (windows version of c/c++ compiler gcc, real and usable in win10)_jjxcsdn's blog-CSDN blog

[2] Detailed explanation of download, installation and use of MinGW and Clion_Clion comes with mingw_Teacher I forgot to bring my homework blog-CSDN blog

1.4 clion usage tutorial

Develop modern C++ cross-platform programs using clion+cmake+vcpkg - personal space of osc_sm6rxbzs - OSCHINA - Chinese open source technology exchange community

Tutorial on using the C/C++ development tool CLion: Configuring CLion on Windows (Part 1) - Programmer's Programming Soul's Personal Space - OSCHINA - Chinese Open Source Technology Exchange Community Tutorial on using the C/C++ development tool CLion: Configuring CLion on Windows (Part 1
) ) - The personal space of the programmer's soul - OSCHINA - Chinese open source technology exchange community

1.5 c++ development tools

Basically there are three types:
VS
VScode
clion

1.6 C++ development application areas

Insert image description here
Insert image description here

Insert image description here

1.7 c++ learning route

C++ learning route and opinions
C++ is roughly divided into four parts: basic knowledge of C++, template C++, Object-Oriented C++, and STL.

Insert image description here

Insert image description here
Insert image description here

Core basics
(1) Data types
(2) Process statements
(3) Functions and classes
(4) Distributed, multi-threaded, etc.
(5) Network programming
(6) File operations
(7) Exception handling
(8) Database operation
extensions
(1) ) Data Structure and Algorithm
(2) Linux
Insert image description here

1.8 c++ learning materials

Just look at the following 2 courses.
1. lx recommends __ courses from Erxue Valley, xm has purchased
C/C++ course outline | C/C++ training course system | Dark Horse C/C++ course schedule

2. Silicon Valley’s 2023 version of C++ zero-based tutorials, practical C++ projects, and Tsinghua’s academics will help you pass the test_bilibili_bilibili

1.9 Four major factions in the programming world

Programming is basically divided into 4 major factions, so if you don’t do java, you will basically do c++.

  1. java
  2. c++
  3. Algorithms (c++ and python) To learn algorithms, you must learn c++ and python
  4. front end

2 Basic grammar

2.1 Introduction to each part of the C++ program

Introduction to the basic components of C++ programs_A blog for software development technology enthusiasts-CSDN Blog

2.2 Writing C++ programs

Insert image description here
How to create a C++ project in Visual studio 2019? _How to create a c++ project in vs2019_That ray of time blog-CSDN blog

2.3 c++ third-party library management

2.3.1 Reference to third-party libraries

Running programs under c++ (installation of third-party libraries and installation of gdal)_c++ installation library_xiaoma bigdata's blog-CSDN blog

2.3.2 Reference other cpp files

Two ways:
1 Directly reference the .cpp file

#include "ctool.cpp"

2. Write header files to reference header files
c++ 05. Reference external files - Programmer's tutorial
on calling functions in other files in C++_c++ functions that reference other files_Blog of bitter classmate Yang - CSDN blog
C++ learning diary - header files Writing_How to write a c++ header file_Xu Nian Fei Huan's Blog-CSDN Blog

2.4 Two methods for compiling c++ programs (MinGW’s gcc and makefile)

Insert image description here

References

[1] Courses from the Erxue Valley under Dark Horse
[1] The ingenuity of Dark Horse programmers | C++ tutorials for introductory programming from 0 to 1, introductory course_bilibili_bilibili
[2] C++ storage class | novice tutorial] (https: //www.runoob.com/cplusplus/cpp-storage-classes.html)

Guess you like

Origin blog.csdn.net/xiaotiig/article/details/129394396