zoukankan      html  css  js  c++  java
  • c++call back

    #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
    "); }
    };
    
    class Window : public View
    {
    public:
        virtual void test() { printf("test A
    "); }
        void func(int * b) { (void)b; printf("************
    "); }
    };
    
    
    typedef void(*HandlerNoParam)();
    typedef void(*Handler1Param)(void* receiver);
    typedef void(*Handler2Param)(void* receiver, int* e);
    
    void test1()
    {
        printf("no parameter test:
    ");
    }
    
    void test2(void* receiver)
    {
        (void)receiver;
        printf("1 parameter test:
    ");
    }
    
    void test3(void* receiver, int* e)
    {
        (void)receiver;
        (void)e;
        printf("2 parameter test:
    ");
    }
    
    
    
    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;
    }
  • 相关阅读:
    NumPy 位运算
    NumPy 数组迭代
    NumPy 广播
    NumPy 基于数值区间创建数组
    NumPy 数组切片
    NumPy 基于已有数据创建数组
    NumPy 数组创建
    NumPy 数据类型
    NumPy ndarray
    区块链技术学习指引
  • 原文地址:https://www.cnblogs.com/zhoug2020/p/6871607.html
Copyright © 2011-2022 走看看