C ++ introduction source code Concise version, C ++ entry-level C ++ learning, the difference between C ++ and C is worth knowing, the source code is known
C ++ introduction source code brilliant version, C ++ entry-level C ++ learning, the difference between C ++ and C is worth knowing
Basic differences between C language and C ++
C ++ Standard Input and Output
Name blank
1. namespace definition:
Namespace identifier {} example: namespace my {int a = 1 ;}
Member access in the namespace: Scope identifier: cout <my: a <endl;
Omit the qualifier (prefix): using namespace my;
Think of the standard namespace: using namespace std; the standard namespace does not have this, you need to add std: cout, std: cin, std: endl;
2. Nesting of namespaces:
Cout <my: danny: B <endl; do not want to use such a long prefix
1: using namespace my: danny;
2: namespace IM = my: danny
Bool: Boolean Type
1. Values: 0, 1, false, and true
2. true and false. Non-zero in the computer indicates true. Only 0 indicates false.
3. Memory occupies 1 byte
Generally used to determine the type of return value of a function
Reference Type
1. Alias Function
2. prevent the generation of copy books
3. Use it as the left Value
4. Reference of the right value: constant reference example: int A (int & mm); A (1) can be used during call );
Heap memory Application
Changed from malloc, realloc, calloc, and free to new and delete.
Struct:
1. Define variables and use struct names directly. The keyword struct can be omitted.
2. The existence of members allowed in the struct and the existence of the constructor
Inline
The inline keyword is used to define an inline function of a class. The main reason for introducing it is to use it to replace the macro definition in expression form in C.
Function overload
Function overload: Allows functions with the same name and different parameters to exist.
1. Different parameter numbers
2. Different parameter types
3. Different parameter types
Function default
Function default: Allows function parameter initialization.
1. The default function is actually an optimization body of overload.
2. The default function must start from right to left.
- This article has been included in the following columns: