1.C ++ in the cast
reinpreter_cast // <-ID type> (expression The)
// type-ID must be a pointer, reference, arithmetic type, function pointer or a pointer member
S SS;
S & SS = PS *;
int = A reinterpret_cast <int> (PS) ; // reinterpret_cast simply copied to bits ps a
COUT a << << "" << endl << ps; // 7208636 0x6dfebc
// type-ID must be a pointer, reference, arithmetic type, function pointer or a pointer member
S SS;
S & SS = PS *;
int = A reinterpret_cast <int> (PS) ; // reinterpret_cast simply copied to bits ps a
COUT a << << "" << endl << ps; // 7208636 0x6dfebc
// const_cast <type_id> (expression) - type_id -> a pointer or reference
// same type_id and type of expression - modify the object const / volatile - forcibly canceled object const
const int CI = 10;
int & BI = const_cast <int &> (CI);
COUT BI << << "" << endl << CI; 10 // 10
COUT BI & << << "" << endl << & CI; // address 0x6dfeb4 0x6dfeb4 same two variable
bi = 8;
<< << BI COUT "" << endl << CI; 10. 8 //
COUT BI & << << "" << endl << & CI; 0x6dfeb4 0x6dfeb4 //
// may be used when the function parameter passing
// same type_id and type of expression - modify the object const / volatile - forcibly canceled object const
const int CI = 10;
int & BI = const_cast <int &> (CI);
COUT BI << << "" << endl << CI; 10 // 10
COUT BI & << << "" << endl << & CI; // address 0x6dfeb4 0x6dfeb4 same two variable
bi = 8;
<< << BI COUT "" << endl << CI; 10. 8 //
COUT BI & << << "" << endl << & CI; 0x6dfeb4 0x6dfeb4 //
// may be used when the function parameter passing
// static_cast <type-id> ( expression) - corresponds most explicit or implicit conversion
// This expression is converted to the operator type-id type, but without run-time type checking to ensure the security of the converted
// dynamic_cast only for pointers and references to objects, mainly used for the implementation of "safe downcast."
Also on the volatile:
volatile similar to the well known const is a type modifier
volatile is to instruct the compiler to illustrate it modifies the object to perform optimization should not be - the role of volatile is used for multi-threaded programming
2. row pointer declaration
int a[5][10];
int (* p) [10] = a; points to a number of elements in each row pointer 10
3. Several file manipulation functions
4. How to convert binary tree forest
First a tree into a binary tree basic principle is: the left child of its true children, their brothers and their children the right
Forest converted to a binary tree:
First tree forest is converted into a binary tree Yi Keke
Do not move from a binary tree, binary tree after the root node as the root node of a binary tree in front of the right child
All the trees to turn into the binary tree
It can be seen: F converted into a corresponding binary tree forest T, the number of middle nodes is equal to F (T empty left child node number)
Because children left their real children, converted to a binary tree in the forest leaf nodes in its left child must be empty
5. When a class object virtual function is called, C ++ uses - static binding
Static binding virtual function is called by the name of the object, at compile time can determine which virtual function call is a class
动态联编 通过基类指针调用,在编译阶段无法通过语句本身来确定调用哪一个类的虚函数,只有在运行时指向一个对象后,才能确定调用时哪个类的虚函数