You can only initialize an array when you define it, you cannot assign an array to another array, but you may assign a value to an array element by using the subscript, but you can assign a string object to another string object
If only one part of the array is initialized, the other elements are automatically set to 0
C++11 can contain nothing in the initial curly braces, which will set all elements to 0.
C++11 suppress narrowing conversions when array list is initialized
C-style string ends with a, not a char-terminated character array not a string
Any two string constants separated by whitespace (spaces, tabs, newline characters) will spell themselves into a
The sizeof operator indicates the length of the entire array, while strlen () indicates the length of the string stored in the array
CIN uses blanks (spaces, tabs, newline characters) to determine the end position of a string, and for word
The Get () function and the getline () function of CIN are line-oriented:
The Getline () function discards a newline character and stops reading when a specified number of characters-1 is read or when a line break is encountered
The Get () function preserves the newline character, and you use the parameterless get () function to read the newline characters before reading the characters again, or you can use the clear () function to restore the input
You can use C-style strings to initialize a string object, use CIN to store keyboard input in a String object, use cout to display a string object, and use array notation to access the characters stored in a string object
C + + takes "(and)" as a qualifier, uses the prefix r to identify the original string (not escaped), and can be used to create custom characters between the original delimiter, with the addition of spaces, opening parenthesis, closing parenthesis, Slash, and other characters outside the control character.
C + + allows you to omit the keyword struct when declaring struct-body variables and use the member operator. To access individual members
C + + does not advocate the use of external variables, but advocates the use of external structure declarations
struct initialization uses a comma-delimited list and encloses these values in curly braces.
C + + allows you to specify a struct member that occupies a specific number of bits, the struct member's field type is integer or enumeration, followed by a colon, a number followed by a colon, so that it can be created on a hardware device with a register corresponding to the data structure, but bit fields are usually used in low-level programming.
A community can store different data types, but only one of these types can be stored at the same time, saving space when data items use two or more data types, and are often used in operating system data structures or hardware data structures.
C++enum provides another form of creating symbolic constants. In the case of no casting, only the enumeration that is used when defining the enumeration is assigned to the variable of such enumeration, and when the arithmetic operation, the enumeration is automatically converted to int, whose result type is int and must be cast to be copied to the enumeration variable
Each enumeration has a range of values, and by casting, any integer value in the range of values can be blessed to the enumeration variable, even if the value is not an enumeration value, the definition of the enumeration range is calculated to include the enumeration of the maximum value of 2 of the n-th square, for example, the maximum value is 108, the maximum value of 128, Its minimum value is-6, the lower limit of its minimum value is-8, the value range is -8~128
To get the address of a regular variable, simply use the address operator &
The difference between object-oriented programming and traditional procedural programming is that OOP emphasizes the operational phase of making decisions.
When using a regular variable, the value is the specified amount, and the address is a derivation; the pointer is the opposite, the pointer name gets the address, and the value is the amount of the derivation. * is an indirect value or dereference operator, applying it to a pointer can get the value at that address
In C + +, int* is a composite type, a pointer to int, and a * for each pointer variable name.
Initialized in a declared statement, the pointer is initialized, not the value it points to.
When you create a pointer in C + +, the computer allocates memory to store the address, but does not allocate memory to store the data that the pointer points to. The golden rule of using pointers is to initialize the pointer to a certain appropriate address before the pointer applies the dereference.
The pointer is not an integral type and cannot be simply assigned to a pointer, and the number should be converted to the appropriate address by forcing the type conversion
The value of the variable is stored in the memory area of the stack, and new allocates memory from the memory area of the heap or free storage area
Use Delete to free memory, do not delete the pointer itself, do not release the memory blocks that have been freed, and do not release the memory obtained by the variable declaration
Do not create two pointers to the same block of memory, as this will increase the likelihood of the error removing the same memory block two times
When you use new and delete, you should follow these rules:
Do not use Delete to release memory not allocated by new
Do not use Delete to release the same block of memory two times
If you use new[] to allocate memory for arrays, you should use delete[] to free
If you use new to allocate memory for an entity, you should use Delete to release
Applying delete to a null pointer is safe
Both C and C + + use pointers to handle arrays, arrays and pointers are basically equivalent, the difference is that the value of the array name is a constant, cannot be modified, the value of the pointer is a variable, can be modified; the sizeof operator is used to get the length of the array, while the pointer is applied to the length of the pointer.
Adds a pointer variable to 1 o'clock, and its incremented value equals the number of bytes that the pointing type occupies
When an array is created using an array declaration, a static binder is used, and a dynamic union is used when an array is created using the new[] operator.
Using the square brackets array notation is equivalent to dereferencing the pointer
For strings in arrays, string constants enclosed in quotation marks, string constants that are described by pointers, they are handled by passing their addresses
Do not use string constants or pointers that are not initialized to receive input.
C + + has three ways of managing data memory:
Automatic storage--local variable--stack
Static storage, variables declared outside of a function or static storage, variables using the static keyword
Dynamic storage of variables---heap->new/delete declarations
Vectors use new and delete to automatically manage memory
When an array object is initialized, the parameters that initialize the number of elements can only be constants.
Arrays and array classes are stored in the stack, and vectors are stored in the heap.
C + + does not check for out-of-bounds errors, and the difference between the bracket notation and the member function at () is that at will catch illegal indexes during run time, and the program will break by default, but run longer.
c++98 New Standard Template Library STL provides a template class vector, which is a substitute for dynamic arrays;
C++11 provides a template class array, which is a substitute for fixed-length arrays