8. advanced features of C ++ Functions
1. Concept of function Overloading
In fact, this part of the author did not explain the internal method of implementing heavy load. The heavy load of C ++ should also be implemented in C language in essence. I have seen the source code of a project before, and solved the Inheritance Problem with pure C code.
Here, reload only indicates that we cannot use the type of the return value to differentiate the reload when writing the reload. Different parameter types should be used.
At the same time, we reiterate the use of extern "C:
What if a C ++ program needs to call a compiled C function?
Assume that the declaration of a C function is as follows:
Void Foo (int x, int y );
After the function is compiled by the C compiler, its name in the library is _ Foo, while the C ++ compiler generates names such as _ foo_int_int to support function overloading and secure type connection. C ++ programs cannot directly call C functions because their compiled names are different. C ++ provides a C connection to exchange the specified symbol extern "C" to solve this problem.
2. Reload, overwrite, and hide member functions
Here we will only talk about the hidden rules in C ++. In fact, hiding rules is not that complicated. In C #, many keywords are used to limit the hidden rules, such as the modifier virtual abstract new of the function. If you are interested, you can read. Net, which you must know, to find out.
The following are the principles:
If the parent class has the same name as the base class function, the virtual keyword is required to overwrite it; otherwise, all are hidden;
If the parent class and the base class function have the same name but different parameters, the parent class function is hidden in any case.
3. Default Value of the Parameter
4. Operator Overloading
5. function inline
I have not figured out the inline function, so I will not take notes here.
Chapter 9, 10, and 11 of this document will not be described. Wait for the next visit.