1, static member function features: 1, can not directly access Non-static member variables (because static member functions do not contain the this pointer), 2, can not declare as const, volatile or virtual;3, do not need to call through the class object. Called directly by the class name, 4, the address type is the ordinary function pointer, the other NON-STATIC member function's address needs to use the class member function pointer to store.
Class base{
static int func1 ();
int Func2 ();
};
Int (*PF1) () =&base::func1;//normal function pointer
Int (base::* pf2) () =&base::func2;//member function pointer
The characteristics of the const member function:
1 The const member function can access non-const data members, const data members, or all data members within a const object;
2 A non-const member function can access a not-to-be-be-member of a const object, a const data member, but cannot access any data member of the Const object;
3) as a good programming style, when declaring a member function, if the member function does not modify the data member, you should declare the member function as a const member function whenever possible.
4 only member functions declared as const can be invoked by a const class object.
2. Static member variables can only be defined outside the class, avoiding changes to static variables when different class objects are instantiated.
3. In order to identify member functions in the mainstream C + + compiler, the function names and parameter lists are usually grouped together to form a unique internal name.
4, virtual function access call:
5, multiple inheritance, if n base classes have virtual functions, then the derived class has n virtual function table. Each virtual function table is generated in the form of an external object and given a unique name.
6. Function invocation Efficiency: Non-member functions and ordinary members and static member functions, the efficiency of the three calls has been, while the virtual function in a single inheritance, multiple inheritance, virtual inheritance, the efficiency will decline. The most efficient is the inline function.
7. If the inline function (inline) is invoked multiple times, a large number of extension codes may be generated, and if there are local variables in the inline function, a temporary object will be generated.
8, pure virtual function: that is, the function has no clear definition, add "= 0" After the argument list, the class containing pure virtual function is called abstract class, cannot be instantiated.
9. For constants in a class, the initialization list is typically initialized with the order in which the initialization is related only to the order in which they are declared. The initialization list has three disadvantages: 1, only the class member variable is public, only can be used; 2, can only specify constants, 3, because the compiler does not automatically execute, there may be initialization failure of the situation.
10,
11,
12,
13, each constructor, you need to wait until the base class constructor all call execution completed, before starting to set the virtual function table pointer, and then can call the correct virtual function entity.
14,
15,
16, the base class pointer to an array of derived class objects, if the use of delete[] pbase delete objects, may produce errors, if the derived class object is an empty class may not error. Only by looping through the array of pointers, deleting the object individually, destroying the data in memory.
Base *pbase=new child[3];
for (int x=0;x<3;++x)
{
Child *p=& ((child*) pbase) [x];
Delete p;
}
17. For a template declaration, only limited error checking can be performed before it is present by a set of actual parameters (that is, determining the type of the parameter). The compiler was unable to detect any syntax-independent errors in the template.
18, template member functions only in the use of the time will materialize, this is to improve the efficiency of time and space, to avoid the materialization of a large number of functions, really use very little.
19, typeID is the key word of C + +, typeID is one of C + + keyword, equate to sizeof this kind of operator. The return result of the typeid operator is a reference to an object of the standard library type named Type_info. Related Detailed introduction: http://www.cppblog.com/smagle/archive/2010/05/14/115286.aspx