通过 void *handel传到参数

通过 void *handel传到参数

typedef struct
{
    int a;
    uchar *ptr;
}EffectParam;


void fun(void* handle)
{
    //if (handle != NULL)
    //{
    //    cout << "handle " << handle << endl;
    //}
    EffectParam *param = (EffectParam*)handle;
    cout << param->a << endl;
    if (param->ptr != NULL)
    {
        cout << "param->ptr " << param->ptr << endl;    
    }
}

void funtest()
{
    EffectParam param;
    param.a = 3;
    param.ptr = new uchar[3];
    void* handel = &param;
    fun(handel);
}


int main()
{
    funtest();
    return 0;
}
原文地址:https://www.cnblogs.com/adong7639/p/15161835.html