c++call back

來源:互聯網
上載者:User

標籤:window   ptr   virt   printf   ***   view   argv   har   call   

#include "stdafx.h"struct A;typedef void(A::*MemFuncPtr) (int* e);class A{    int a;}; class View : public A{public:    virtual void test() { printf("test A\n"); }};class Window : public View{public:    virtual void test() { printf("test A\n"); }    void func(int * b) { (void)b; printf("************\n"); }};typedef void(*HandlerNoParam)();typedef void(*Handler1Param)(void* receiver);typedef void(*Handler2Param)(void* receiver, int* e);void test1(){    printf("no parameter test:\n");}void test2(void* receiver){    (void)receiver;    printf("1 parameter test:\n");}void test3(void* receiver, int* e){    (void)receiver;    (void)e;    printf("2 parameter test:\n");}int _tmain(int argc, _TCHAR* argv[]){    Handler2Param p0 = (Handler2Param)test2;    p0(NULL, 0);    MemFuncPtr p = (MemFuncPtr)&Window::func;    Window a;    (a.*p)(NULL);    getchar();    return 0;}

 

c++call back

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.