C++ FUNDAMENTALS 

(By Dr. Leo Hu)


This handout is suitable for beginners to intermediate learners who study C++ systematically, and it can also be used as a reference tool for common knowledge points of C++.

If you have no knowledge about C++ programming, please go over C++ in 1 hour first. 

Please use this online C++ compiler IDE to test the programs in this handout and develop your own programs in learning.

1.Tools for C++ programming 

When we prepare a C++ program, we must use an editor to write the source code of the program.  Since source code must be pure text (ASCII characters), the editor must be a pure text editor such as Notepad in Windows, or vi in Linux or Unix, etc. 

Any program of source code written in a high-level programming language must be translated into machine code before it can be executed by a computer. There are two ways of translating source code into machine code: compiling and interpreting. 

Compiling is the process of converting source code into machine code before the program is run. Interpreting is the process of translating source code into machine code one line at a time as the program is running.  The tool for compiling is a compiler, and the tool for interpreting is an interpreter. 

C++ is a compiling language. Therefore, we need a C++ compiler to translate a C++ program into machine code. There are quite some C++ compilers available such as GCC (GNU Compiler Collection) , LLVM Clang, etc

Since a C++ program source code may be written in multiple modules stored in a few files, and a program may need use code in predefined libraries, a linker is usually needed to link the modules and libraries together to form an executable program. 

While we can use the independent editor, compiler, and linker in programming, we prefer to use an Integrated Development Environment (IDE) that has integrated the editor, the compiler, and the  linker to work together. There are many IDEs available such as Eclipse IDE for C++, Microsoft Visual C++, C++ Builder, etc., and also many online IDEs such as programiz.com, CodeChef IDE, OnlineGDB, Paiza.io, onecompiler, and so on. 

In this lecture, we will use programiz.com for programming demos and for hands-on practices. The programiz.com IDE in a browser looks like the figure below.