High quality c ++ programming guide five notes after reading

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.