C + + class function pointers

Source: Internet
Author: User

In the study of quick-3.3, tracing the function of the Touch Event Distribution section found a rare (odd) notation:->*.

void Widget::p ushdownevent () {    this->retain ();    if (_toucheventcallback)    {        _toucheventcallback (this, Toucheventtype::began);    }        if (_toucheventlistener && _toucheventselector)    {        (_toucheventlistener->*_toucheventselector) ( This,touch_event_began);    }    This->release ();}

After investigation this is the legendary class function pointer, you write an example to test.


Fucktest.hclass fucktest{public:void shitFunction1 (void) {printf ("Liujianlog:call  ShitFunction1");} void ShitFunction2 (void);};


#include <stdio.h> #include "FuckTest.h" typedef void (fucktest::* shitfunctionoutside) (void);//define a class member function int Main (int argc, const char * argv[]) {shitfunctionoutside shitfunctionoutside= &FuckTest::shitFunction1; Fucktest fucktest; (fucktest.*shitfunctionoutside) ();//here. *    return 0;}


C + + class function pointers

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.