Declare the callback function in C ++

Source: Internet
Author: User
When using SNMP ++ to develop network management software, you need to send request packets asynchronously. You need to register a callback function in the function, specifically: typedef void (* snmp_callback) (INT reason, SNMP * Session, PDU & PDU, snmptarget & target, void * data), starts to declare the callback function as a private member in the form of void getcallback (INT reason, SNMP * session, PDU & PDU, snmptarget & target, void * data); but it is always saved during compilation. The error message "unresolved overloaded function type" is displayed. : <, I have carefully checked the return values and parameters of the function and found no problems. It has been plagued for a long time. Later, I found that the callback function in C ++ cannot be declared as a non-static member of the class, because the non-static member function will add the this pointer to the parameter during compilation, the parameter list will change, so we should Static functions declared as global functions or classes.

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.