[C ++] function concept

Source: Internet
Author: User
There is only one 'true' function, corresponding to the JMP in the Assembly, that is, jump to a specific address for execution.

Global functions, local functions, member functions, static member functions, and virtual functions are all delicious syntactic sugar.

Global functions are basically functions in the original sense.
Local functions (static global functions) only restrict the permission of local CPP in GCC.CodeJMP in the past. In fact, this concept does not exist at the assembly or binary level. Pure syntactic sugar.
The member function only adds the class-based prefix to the function by GCC, and then adds the this pointer parameter. In fact, after GCC compilation, it becomes a global function, but the function name is special. Pure syntactic sugar.
The static member function is the same as the member function, but the fixed parameter * This is missing. Pure syntactic sugar.
There are a lot of people familiar with virtual functions. I will not elaborate on it. It is also JMP in the end. It's just that JMP had to get the target address of JMP through computation. More complex syntactic sugar.

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.