Share what you have recorded on your impression notes ...
1. Conditions that must be used to initialize the list: 1> constant member Const: Constant members can only initialize 2> reference types that cannot be assigned: must be initialized at definition, and cannot be assignable 3> class type without a default constructor: Because using an initialization list eliminates the need to call the Default constructor to initialize, instead of calling the copy constructor initialization directly.
2. Small-end mode high address storage, low address storage lows
3. The difference between a struct and a consortium is the same: you can construct different points of data types: the length of memory that a struct variable occupies is the sum of the memory length of each member. Community variables take up memory lengths of the longest members. Several different types of variables share a segment of memory. All members cannot exist at the same time. Struct and union mainly have the following differences:
1. Struct and Union are composed of a number of different data type members, but at any one time, only a selected member is placed in the Union, and all members of the struct are present.in struct, each member occupies its own memory space, and they exist at the same time. The total length of a struct variable equals the sum of all member lengths. In union, all members cannot occupy its memory space at the same time, they cannot exist at the same time. The length of the union variable equals the length of the longest member. 2. Assigning values to different members of the Union will be overridden for other members, and the value of the original member does not exist, and the assignment of different members of the struct does not affect each other.
The Union does not support inheritance, cannot define virtual functions, the default access rights are public, and member types cannot be static and referenced.
4.const, volatile const int i=0; After modifying the value of I through the pointer, the value of variable I at compile time is known, and the compiler replaces the variable I of printf output directly with 0. If I is the volatile const int type, then the compiler does not optimize the variable i, and printf the output as a modified value.
5.fork each fork () comes out of the new process and the parent processUse the same code snippetAndcopy a data segment and stack segment of a parent process。
Complete binary tree N0 for 6.N nodes is the total number of nodes (that is, the number of leaf nodes) with a degree of 0 N1 is the total number of nodes with degrees 1 N2 is the total number of nodes with degrees 2
by N=n0+n1+n2 N-1=n0*0+n1*1+n2*2 =====>n0=n2+1 (the formula of binary tree)
For complete binary trees, n1=1 or 0 n0= (n+1)/2 or N/2
6. Static binding, dynamic state static binding refers to the object when the pointer points to the declaration. Dynamic bonding refers to a pointer to a referenced object.
7. #define code in the face of #define, it is directly define defined content to replace the contents of the source code
8. Enum type enum enum default type is int all enum type size is 4
9. Virtual functions to correctly implement virtual functions, can only use a base class pointer or reference to point to the derived class object.
10. Undefined behavior 1> The calculation Order of multiple operands in the same operator 2> the evaluation order of the parameters of the function 3> directly modify the value of the const constant by pointer 4> except for 0 5> some pointer operations can also cause undefined Behavior 6> a function that requires a return value, but no returns statement.
11. Array first address array the first address is a constant and cannot be assigned a value
12. Pointer array, array pointer [] priority is higher than *.p First and [] The combination is an array, first and * is the pointer.
The difference between 13.a and &a &a is the first address of the entire array, and a is the first address of the array element. Values are the same, but different in meaning.
&a+1=&a+sizeof (a) *1 is the address of the next array (a+1) representing the next address of the first address of a[0], that is, the address of the a[1]
14. Federation Union 1> Federation variables can be initialized when they are defined, but the members of a consortium cannot be initialized when they are defined. The members of the 2> consortium are common, and only the current members are valid at some point. 3> Federation variable The memory size of comrade-in-arms is the storage space of the longest member in the consortium.
15. The memory space of static data member static member variables is not allocated when the class is declared, nor is it allocated when the object is created, but when it is initialized
A static member variable is independent of the object, consumes no memory of the object, and instead creates memory beyond all objects, even if you do not create an object
Static members of a class cannot be initialized within a class. Both class names and objects can call static data members directly.
16. Default parameter values that do not redefine inheritance the virtual function is dynamic binding, and the default parameter is static binding. Calls a virtual function that is defined within a derived class, but is the default parameter value specified by the base class for it.
17. Logical structure, storage structure logical structure: linear logic, nonlinear logical storage structure: linear, chain, hash, index
18. Pass pointer value if a function can modify the value of a pointer, you must pass a pointer to the function. If only the value of the pointer is passed, a copy of the pointer is generated (but the pointer points to the same location)
19. The default parameter of function default parameter is to assign value from left to right. When you define a function prototype, if a parameter has a default value, the following argument must have a default value.
20. Two-d array pointer int sec[2][3]={1,2,3,4,5,6}; int **p=sec; Then **p=sec[0][0]; *P=SEC[0]; * (P+n) =sec[n]; * (* (p+n) +m) =sec[n][m]
21. Default copy constructor Shallow copy
22. Encapsulation Inheritance Hosting overlay hidden encapsulation: encapsulate objects into abstract classes, and classes can put their own data and methods to manipulate only trusted classes or objects, and hide untrusted ones. Inheritance: You can use all of the functionality of the base class, and you can extend the functionality without rewriting the class. Overload: A function of the same name defined in the same class with different parameter types and number requirements. Overrides: A derived class overrides a function of the same name in a base class that requires the number of parameters, type, return type, and the function of the base class must be a virtual function. Shadowing: A function in a derived class masks a function of the same name in a base class. And the function is not a virtual function in the base class.
23. The invocation order of the constructor calls the constructor in the parent class, calls the constructor of the member object, and finally calls its own constructor. The destructor is the opposite of the above.
24. A virtual function with a virtual function of the class, the object of the first 4 bytes is a virtual table pointer
25.malloc memory leak memory leak as long as the reason is the dynamic application of a piece of memory in the program, after use did not release in time. This causes the program to consume a large amount of memory. malloc is applying for a virtual address.
26. A private destructor defines a destructor as private, then the class can only create objects from new. When the compiler allocates stack space for a class, the the accessibility of a class's destructor is checked first, except for destructors, as long as non-static functions, the compiler checks, and if the destructor of the class is private, the compiler does not allocate memory for the class on the stack space.
Constructors are private and can prevent class instantiation. (Nursery rhymes can prevent class instantiation and pure virtual functions)
27.this pointer this pointer is a constant pointer and is not allowed to be modified.
28. Left and right values if the expression can be addressed, it is the left value, otherwise the right value. The left value can appear to the left and right of the equal sign only on the right side of the equal sign
In C + +, temporary amounts (the right values) can be passed to the function, but can only be received as Const & type.
A very strong left-value reference (double &r=i;) can only be bound to a very strong left value, and cannot be bound to a constant left value, a very measured right value, and a constant right value. Illegal: int &r=3; The initial value of the extraordinary reference must be a left value.
A constant left-value reference (const double &r=i;) can be bound to a value of all types, including a very left value, a constant left value, a very good right value, and a constant right value. Legal: const INT &r=3;
29.c++ is a static data type language, and type checking occurs at compile time.
30. Type conversions when an arithmetic expression has both an unsigned number and an int value, the int value is converted to an unsigned number. Negative numbers are converted to unsigned numbers: The negative number plus the unsigned modulus (that is, the complement form: take the reverse plus one)
31. It is legal to call delete this in a member function of a class. The memory space of the class object is freed and, in subsequent function calls, works correctly as long as the contents of this pointer are not involved. Otherwise, there will be unexpected problems.
Calling delete this in a destructor of a class causes a stack overflow. Because the essence of delete is: Call one or more destructors for the memory that will be freed, and then free up memory to cause infinite recursion, stack overflow.
32. Declaration and definition statement: Yes, the name is known to the program, a file must contain a declaration of that name if it wants to use the name defined elsewhere.the declaration stipulates the type and name of the variable。 Tell the compiler what type of name (function). Variable. Other) Definition: responsible for creating the entity associated with the name.Request Storage Space, you may also assign an initial value to a variable.
A declaration can be multiple times, and can be defined only once.
33.const objects can only invoke const type member functions. A virtual function cannot be an inline function, a static member function, or a constructor function.
The effect of 34.const and static cosmetic global variables is the same: it cannot be invoked in other modules with extern
35. Pointers and const hold the address of a constant object, only pointers to constants are used. Allows a pointer to a constant to point to a very object of magnitude. Pointer to a constant: You cannot change the value of an object through this pointer. The const pointer must initialize: once initialized, its value (stored as an address) cannot be changed.
36. Top and bottom const 1>* the left side of the bottom const,* right is the top-level const 2> the const used to declare references is the underlying const 3> when the copy operation of an object is performed, the copied and copied objects must have the same The underlying const eligibility, or the data type of two objects must be convertible. 4>constexpr the object it defines for the top-level const (constant pointer) 5> the address of a constant object is a low-level const
37. destructor virtual function destructors can be virtual functions, but do not call virtual functions in a destructor. Do not call virtual functions in constructors either. The reason for not calling virtual functions in destructors: Because destructors are the first to destructor derived classes, in the destructor base class. If a virtual function is invoked in a destructor of a base class, it is dangerous to invoke a function in a subclass object that is already destructor, depending on the dynamic binding. The reason for not calling a virtual function in a constructor is that a virtual function called inside a constructor is not a virtual function, but is statically bound.
38. Operator's evaluation order logic and, logic or, condition (. :) and all good operators are computed in order from left to right.
The result symbol for the 39.% and/operator m%n is the same m/n as the symbol for M and the M and N symbols.
40. Type conversions in most expressions, integers smaller than int are first promoted to a larger integer type. An integer type is converted to the appropriate floating-point type when there are both floating-point numbers and integer types in the expression. An unsigned type of an Operation object, a signed type 1> unsigned greater than or equal to a symbol: signed to unsigned type 2> Otherwise, if all the unsigned values can exist in a signed type, unsigned---is signed, otherwise signed---"Unsigned"
41. Use constants to refer to the type of arguments that the normal reference maximum limit function can accept.
42. Returning the referenced function is the left value, meaning that the functions return the object itself, not a copy of the object.
43. Constant functionthe const, immediately following the argument list, indicates that this is a pointer to a constant。 (This is itself a constant pointer) such a member function is called a constant member function. In general, this is a constant pointer to the extraordinary amount.
44.vector
The reserve is a container reservation, but does not really create an element object and cannot refer to elements within the container until the object is created, so when you add a new element, you need to use the push_back ()/insert () function. Resize is to change the size of the container and create the object, so after calling the function, you can refer to the object within the container, so when you add the new element, use the operator[operator, or use an iterator to refer to the element object.
45. The priority queue Priority_queue Priority_queue is based on vector implementations. Stack and queue are implemented based on Deque.
46. The two-D array definition must indicate the number of columns: The compiler addresses the number of columns.
47. The compatibility of a derived class and a base class cannot assign a base class object to a derived class object, and the address of a base class object cannot be assigned to a pointer to a derived class object, and a base class object cannot be cashed as a derived class. A derived class object can access a member of a base class only if the base class member is not overridden by a derived class.
48, shift operation INT a=1,b=32; The result of the a<<b is 1: Before the shift, in order to prevent the shift number out of bounds, first b&31=0, so actually for 1<<0=1 and if direct 1<<32, the result is 0
49. Solution to hash conflict open addressing: Probe the empty position in which new elements are allowed to be inserted in a specified order. Requires a small loading factor, when the node size is large, will waste a lot of space. Nodes cannot be deleted directly, only tokens can be made. Zipper method: A single linked list is built for each hash address in which all synonyms with the hash value are stored. The average lookup time is short, the node dynamic request on the single linked list can not determine the table length before Cong; The deletion node is easy to implement. The disadvantage is that the node size is small, the pointer space is relatively large.
50.dynamic_cast as a transformation between object inheritance. Converts a base class object pointer (or reference) to an inherited class pointer. To have an inheritance relationship dynamic_cast will handle type conversions. dynamic_cast the pointer, the failure returns null, the pointer after the successful return of the normal cast dynamic_cast the reference, the failure throws an exception, successfully returns the cast after the reference.
51.new and delete dynamically allocated objects are initialized by default. NEW: Allocates memory and calls object constructor Delete: Invokes the destructor of the object and frees the pointer that memory passes to delete must point to dynamically allocated memory, or a null pointer changes to a null pointer after delete. Point to a pointer to a memory that once saved the data object but is now invalid. You can assign nullptr to a pointer after the delete.
52. Value initialization, the default initialization value initialization of the built-in type object has a well-defined value (such as int is 0,string is an empty string) the default initialization of the object's value is undefined.
53. A synthesized destructor does not delete a pointer data member
54. Classes that require a destructor also need to copy and assign operations the class that requires the copy operation also needs to be assigned a value operation
55.=default and =delete =default display requires the compiler to generate a composite version only use default for member functions with a composite version, such as default constructors and copy control functions =delete Delete functions must appear at the first declaration of the function. You can specify =delete for any function
Destructors are members that cannot be deleted. Classes that want to block copying should use =delete
56. The regular member function declaration format of the class is: Type descriptor function name (parameter list) const;
57. Stable sort: Insert, bubble, merge, cardinal
58. Dynamic binding of virtual functions is onlybase class pointer or a reference to a bound derived class objectHappen.
59. The method of making a function known as an inline function: implicitly defining a function in the class as shown in front of the function plus inline