c ++ primer plus study notes

My machine with Xcode, in bytes
0 is the beginning of octal
0x hexadecimal
cout default output is 10 hexadecimal
wchar_t bytes wide, which is a sufficiently large integer type, it can be used to indicate that encoding such as Chinese
 
 Once defined the constants c, can not be modified (const)
Floating-point number, c ++ floating-point number consists of two parts in the computer memory, a portion of the base, used to represent a portion of a floating-point, this is represented by a binary floating-point.
Very large or very small numbers can be represented by the notation e
 
The program fully demonstrates the problem precision, double precision can save more. For c ++ float it can only be saved six significant figures, if more precision is required, use double. By default, floating-point type is double.
 
It relates to the number of different types of computes, first put into a small number of precision accuracy a large number.
auto equivalent type var
Try to let the compiler to compute the number of elements more secure. Longer than the array of strings, there is no harm.
Difference 's' and "s" is, 's' is a single character, a representative of ASCII code, and "s" represents 2 characters 's' and '\ n'.
Cin in using get () or getline (), getline () to read a statement.
 
It can be accessed as an array to access the string type.
The difference between the operation of the difference between character arrays and string.
For use in the character array <cstring> class have strcpy, strcat, strlen to replicate and ligation.
The size of the string can be adjusted automatically, that is to say after the string can continue to add a string type variable
The array of characters can not.
For character arrays, if not defined on the use of strlen method to the array length, it may vary with the length of the array of characters defined. strlen to calculate the number of bytes from the beginning of the first element of the array until the null character. For uninitialized array, null character occurs is random, so that the resulting length of the array may be different definitions
 
 
The difference between struct, union of
union use only a single member variable, member variables in a memory.
Enum type ranges from a minimum of 2 greater than the maximum power of minus one.
double-byte int float4 occupies 8 bytes (I)
Note that the following special case when the pointer used
Here is a description of the pointer is initialized to the address of the allocated memory space, but he did not value the content distribution space, so direct that he's content to a single value is wrong.
 
In fact, arrays and pointers have a great relationship, can be seen as a pointer to an array, the array is defined, you can use the pointer operator to operate the array,
 
cin and cout for the use of pointers, for character arrays and string passed is an address, and the address of the first character.
So cout << ps ----- can print their values, if you want to display their address address << (int *) ps, this time will be printed ps pointer and string is cout.
But for value types, such as int * p cout << p p is the print address.
 
 chark[]="helloworld";
   char* ps=newchar(strlen(k)+1);
    strcpy(ps,k);
Create a new copy
With strcpy and strncpy to be assigned to a string array.
 
Here is equivalent to c # in the foreache statement, if you want to change places with an array of values ​​& x, and the output of the direct x;
EOF is the use of a combination xcode of ctrl + d.
c + a pointer in the array is initialized to a set of string constants;
cin >> c; this expression will have a return value, such as c is an integer, but the input is a string, false is returned, the input string is stored in the cache.
 
c ++ function can not return a string so he can only return address
To create this function when a new pointer variable length length of the string plus one last assignment to n + 1
// c ++ function pointers - a correction needs are enclosed in parentheses
double calculate(double x,double y, double (*p)(double,double)){
return p(x,y);
}
 
c ++ generic method when there is a special type requires special treatment may take
template<> char * maxn<char *>(char * arr[],int arrSize)
The display statement.
chaff * sc = new (buffer) chaff [2]; // method 1 ---- created in the first element of the buffer memory, a buffer array, these two elements share one memory space
 
State exists for a variety of things, usually by declaring a public enumeration, add the private attribute object to indicate different states, such as Cartesian coordinates and polar coordinates
For overloaded assignment operator, the constructor if the new operator, which here need to clear the current memory, then an assignment at the
 
3. Template type:
Type template is not a real type, it must wait until the final to determine the type of the type of binding, so when instantiating a template, you must be able to allow the compiler to "see" where the use of a template, but must see the exact template definition, not just their declarations are compiled code can not be produced smoothly. Thus, the standard will require the instantiation of the template into the body and defined in the same compilation unit.
 
Role of the virtual base class:
On the basis of multiple inheritance, the subclass inherits the multilayer inherits from the same base class methods
 
 

Reproduced in: https: //www.cnblogs.com/KyleRuan/p/4322399.html

Guess you like

Origin blog.csdn.net/weixin_33860528/article/details/93435604