简体   繁体   English

将C函数数组转换为C ++函数指针数组?

[英]convert C function array to c++ functions pointer array?

im working on converting C code to c++ , in one section of the code i have something like function array in C that looks like: 我正在将C代码转换为c ++,在代码的一部分中,我有类似C中的函数数组的内容,如下所示:

this is how C looks like : 这是C的样子:

void func1(bool a)
{
..
}

void func2(bool a)
{
..
}

void func3(bool a)
{
..
}


struct func
{
    void (*f)(incoming *);
    int arg_length;
};
typedef struct func func;

func funcs[] = {
        { func1, 4 }, 
        { func2, 10 }, 
        { func3, 4 }  
    };

how can it converted to c++? 如何将其转换为C ++?
UPDATE: 更新:
question: is this is valid answer for none static function pointers ? 问题:这是没有静态函数指针的有效答案吗?
http://www.newty.de/fpt/fpt.html#chapter2 http://www.newty.de/fpt/fpt.html#chapter2

also can i define Array of different types of member function pointer? 我也可以定义不同类型的成员函数指针的数组吗?

您可以定义一个类,并插入“ []”运算符以获取指向函数的指针。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM