1.Static
Staic Features: Only initialized once, there is a static zone, different from the auto variable, there is Yu Ching (function end, also destroyed).
Staic within a class: static data members must be initialized outside the class, static member functions can only call static variables, neither can be called with the this pointer.
2.Const
const int *a== int const* A A variable, a pointed object is not mutable
int* Const A:A Immutable, pointing to object variable
3.Switch
If the switch break is not written, it will be executed on the statement that satisfies the condition, until break, or the function ends;
4. Why:
Char str1*= "ABC";
Char str*2= "ABC";
STR1==STR2 established? ABC is stored in a constant area, and most compilers keep only 1 copies of the same constants, so str1 and str2 point to the same address.
5.Assert
The difference between assert and assert: The former is in the debug version, the relase version does not exist, and the assert will exist;
#define NDEBUG can prohibit calling macros;
6.enum
Enum (a,b=1,c,d=2,e) = = 0,1,2,2,3
7.ARGC and argv[]
(test.c) int main (int argc,int*argv[]) {...}
Command line input: Hong bi yue I
Argv[]=[test, Hong,bi,yue,i];
argc=5;
After the 8.main function is finished
After the main function finishes, if you want to continue executing the code, you can then perform the destructor
9.++
A.
*p++: *p-p++ address plus;
(*p) + +: (*p) + + value plus;
B.
S++=5: Error, first executes the address of a, mount the register, and then the temporary variable is the value of a plus 1, the program does not allow the assignment of temporary variables;
++s=5: Correct, take a address, content +1, put register;
10. Notes on floating-point numbers:
float A,b,c;
1.if (a==0): Floating point number has a precision problem, not an exact value, need to convert to: >= or <=;
2. A+b=b+a;
(a+b) +c is not necessarily equal to: (a+c) +b floating-point operations can not be combined------------??? Don't understand
The 11.String class implements the point of note:
1.String:: String (const string &another)
{
char* m_data; To invoke the strcpy () function, use the pointer
m_data= New Char[strlen (another.m_data)+1]
strcpy (M.data,another.m_data);
}
12.extern and Export
Note: The general definition of a variable in the header file will cause a duplicate definition, that is, using the #ifdef, although the header file is only compiled once, but the variable is not only defined once;
Extren int n;
Export Template<class t> void f (t& T);
13 Memory allocation
(1) symbol start block (BSS): Static data + uninitialized global data
(2) Data segment: Static memory allocation, initialized global data
(3) Code snippet: Program execution code
(4) Heap: Dynamically allocated Memory: malloc and new
(5) Stack: Temporary creation of local variables
C + + Interview Basics