1. Declarations and definitions
A declaration is a compiler that describes a name-identifier, which tells the compiler that "this variable or function can be found somewhere, it looks like". The definition is: "Create a variable here" or "Create a function here" to allocate storage space for variables and functions.
2. Translation of language
Any computer language has to be converted from a form that is easy to understand (the source program) into the form of machine understanding and execution (machine instructions), and compilers and interpreters are two translation tools.
3. Order of Links
Because the linker looks up files in order, you can use a custom function instead of a library function if the user customizes a function with the same name as the library function and inserts the file with the function into the list of library function file names. It's possible that this is a bug,c++ namespace ban. The linker will secretly chain some of the modules when creating a C + + executable program. One of these is the startup module, which contains routines for program initialization, which is a program that must be executed first when a C + + program executes, primarily creating stacks and initializing certain variables in the program.
The standard library only needs to add header files, which should always be found for library files. If you use an attached library file, you must add the corresponding file to the list of lookup files for the linker.
4. The Library of the entire C is included in the C + + standard library by default.
The 5.iostream class can read and write data from files, standard input (often referred to as consoles, but also redirected to files and devices).
6. Operator overloading,<< and cout objects together are "send to", and integers together are "left shift".
7. Namespace c all functions and variable names in the same space, large projects, several people jointly developed is, named very carefully. C + + uses the namespace keyword to solve this problem, all the C + + standard library names are divided into the same space Std.
--------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------
1.wchar_t and char16_t, char32_t difference: The latter two are the newest standard additions.
#include <iostream> int main () { wchar_t ch = ' high ';//wide characters char16_t and char32_t are C11 new additions, this machine does not support Std::cout < < ch << Std::endl; return 0;}
2.Hello world!
#include <iostream>usingnamespace std; // scope? int main () { cout<<"" <<8 <<"today! "<<Endl; return 0 ;}
e:\mydocuments\gun\c++>g++ Demo.cpp-o Demo.exe
E:\mydocuments\gun\c++>demo.exe
Hello world! I am 8today!
E:\mydocuments\gun\c++>
3. Input and output stream: Multiple formats for data output
#include <iostream>using namespaceStd//scope? intMain () {cout<<"A number in decimal"<<dec<< the<<endl;//decimal dec<<15cout<<"A number in octical"<<oct<<0x0F<<endl;//octal oct<<15cout<<"A number in hexadecimal"< the<<endl;//Hex hex<<15cout<<"A Float number"<<3.14159268<<endl;//How much precision? cout<<"non-printing char (Escape)"<<Char(0x1B) <<Endl; intNumber ; cout<<"Enter a number"<<Endl; CIN>> number;//The default input is decimalcout<<"value in octical = 0"<<oct<<number<<Endl; cout<<"value in hexadecical = 0x"<Endl; return 0;}
E:\mydocuments\gun\c++>demo.exe
A number in decimal 15
A number in Octical 17
A number in hexadecimal F
A Float Number 3.14159
Non-printing char (Escape)
Enter a number
15
Value in octical = 017
Value in hexadecical = 0xf
E:\mydocuments\gun\c++>
4. Call other programs: the standard C-language system () function, C + + can call any program, System () in the header file Cstdlib (from the original stdlib).
#include <cstdlib>using namespaceStd//scope? intMain () {//System ("Hello");/*E:\mydocuments\gun\c++>demo.exe ' Hello ' is not an internal or external command, nor is it a program or batch file that can be run. E:\mydocuments\gun\c++>*/ /*function: Issue a DOS command usage: int system (char *command); */System ("dir"); return 0;}/*Output: Results and the same effect as entering dir directly below the command line (listing files for current purposes) e:\mydocuments\gun\c++>g++ Demo.cpp-o demo.exee:\mydocuments\gun\c++> The volume in Demo.exe drive E is the serial number of the DATA volume is the ec10-1c79 e:\mydocuments\gun\c++ directory 2015-08-25 11:21 <DIR>. 2015-08-25 11:21 <DIR>. 2015-08-25 10:41 496,719 a.exe2015-08-25 11:21 341 demo.cpp2015-08-25 11:21 15,883 D EMO.EXE2015-08-21 09:52 111 gun.bat 4 files 513,054 bytes 2 directories 81,164,349,44 0 Available Bytes E:\mydocuments\gun\c++>dir--------Direct Output dir command the volume in drive E is the serial number of the DATA volume is ec10-1 C79 E:\mydocuments\gun\c++ 's catalogue 2015-08-25 11:22 <DIR> 2015-08-25 11:22 <DIR>. 2015-08-25 11:21 341 demo.cpp2015-08-25 11:21 15,883 demo.exe2015-08-21 09:52 11 1 gun.bat 3 files 16,335 bytes 2 directories 81,164,349,440 free bytes e:\mydocuments\gun\c++>*/
C + + programming ideas