Static
A static data member of a class is a member of a property that is used to represent a class , not an object.
needs to be accessed by the name of the class , plus the keyword: static
Inline
inline function: A call to replace a function with code in the body of the function when it encounters a call to an inline function
C + + provides inline keyword inline for true embedding.
Inline does not have semantic errors, and it avoids stack and stack , but excessive use of inline can create space for code snippets
Four conversion forms introduced in C + + type conversion
Static type conversion static_cast< target type > (identifier)
Dynamic type conversion dynamic_cast< target type > (identifier)
Re-interpreting type conversion reinterpret_cast< target type > (identifier)
Constant type conversion const_cast< target type > (identifier)
System String Class
The string is actually equivalent to char * in its package , but the value of the defined string can be modified
Five types of initialization
String s= "Hfiurgas";
String SS ("Adfviqrgn");
String St (s);
string str3 = str2;
string *ps= new String;
Structs can only encapsulate data, struct default data is the public property, and this type of encapsulation does not bind data operations together, only through functions to encapsulate.
Class packages data and behavior, masks data externally, provides interfaces, internally shares data, uses methods, and class default attributes are private.
List of parameter initialization
Advantages: High efficiency, the function has not been compressed stack before the initialization of the
Public:student (String sn): name (SN), Len (Sn.size ())
{
}
Copy Builder (copy contructor)
Class A
{
A ( const A & another)// oft-quoted const &
{}
}
Deep copy and shallow copy
Shallow copy: The equal-bit copy can meet the demand without the heap space, if there is a heap space, it is easy to cause double free
Deep copy: If there is a heap space, special handling is needed, that is, rewrite the copy construction . Once overridden, the system is no longer available by default.
The system-provided custom copy constructor is a shallow copy process , and if the data on the heap is involved in multiple destructors , it is necessary to define the copy constructor to implement the deep copy . Avoid issues such as two releases .
Operator overloading =
1. The assignment between objects is completed-
2. Return A reference to a class name
Class Name & operator= (const class name & another)
Memory is divided into four zones: program code area, global data area, heap, stack, and only the heap is left free for the program to run.
function parameter passing: pass by value, pass by address, pass by reference
External Variables extern implementation sharing between files
3 types of Species: class, structure, Union
The function defines the body as an identifier when it is outside the class:
Summary of C + + features