Summary of C + + selection questions (Callback function | | class method (instance method) | | )

Source: Internet
Author: User

callback function: A function that is called through a function pointer . When a function pointer is passed as a parameter, and the pointer is used to invoke the function it points to, we say this is a callback function.

A callback function is not called directly by the implementation method of the function, but is invoked by another party when a particular event or condition occurs, and is used to respond to the event or condition.

The callback function is a bit like a BP machine: Tell someone the number, call you when it has something

Callback is used for inter-layer collaboration, the upper layer of the function is installed on the lower level, this function is a callback, and the lower class triggers a callback under certain conditions, for example, as a driver, is a bottom, he received a data, in addition to the completion of this layer of processing work, will also be a callback to the upper application layer for further processing This is common in hierarchical data communication.

In fact, callbacks and APIs are very close, and their commonalities are functions that are called across layers. But the difference is that the API is the lower level of the call to the upper layer, generally this function is known to the upper level, and the reverse is the opposite, he is the upper level to provide to the bottom of the call , for the lower layer he is unknown, must be installed by the high-level, This installation function is actually a low-level API, the post-installation low-level does not know the name of the callback, but it through a function pointer to save the callback, when it is necessary to call, simply reference the function pointer and related parameter pointers. In fact: The callback is the function written in the upper layer, the lower layer through a function pointer to save the function, at the trigger of an event, the lower level through the function pointer to call the upper function.

Member methods, also known as instance methods, are static methods, also known as class methods

Summary of C + + selection questions (Callback function | | class method (instance method) | | )

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.