This week, C + + object-oriented advanced programming is mainly about three aspects
1. Virtual tables and virtual pointers
Virtual pointers: If there is a virtual function in the class (including the parent class), there must be a virtual pointer, which is a virtual table pointing to the virtual function.
Virtual table: A table of a class that a virtual pointer points to, and a pointer to the implementation of a virtual function inside a class on a table
Here the virtual function and the virtual table are generally combined with the multi-nature of the class to use, the subclass calls the virtual function by calling the virtual pointer to call the virtual function table inside the pointer again to implement the function characteristics
This method of invocation is called dynamic binding, which is an object that is automatically judged by the pointer type, which can be used to invoke the corresponding function without distinguishing which object in the implementation.
The function inside our normal invocation class is called static binding.
2. Const
A lot has been mentioned in the previous study of Const, which is explained in more depth today.
From this table we can see that the constant object can not call the very amount of the function
So when we write some class member functions, if this class does not change the class members, try to add a const
Otherwise, there is a constant object, but the question of the member function cannot be called
3, New and delete
Before we briefly introduced new and delete, here is the main explanation for the overloads of new and delete
The overloaded mode is divided into
1. Global overloading
2. Overloading in class
3, placement overload
One of the placement overloads here is that after we reload new (XX,XX), we also reload the delete (xx,xx), but we
No other version of Delete is invoked at the time of invocation, and the corresponding version of Delete is invoked only when placement new throws an exception.
Some versions don't appear here either.
Boolan C + + Object-oriented advanced programming learning Week Fifth