转换C函数数组C ++函数指针数组? [英] convert C function array to c++ functions pointer array?

查看:108
本文介绍了转换C函数数组C ++函数指针数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IM基于C code转换为C ++,在code的一个部分工作我有这样的事
在C函数数组如下:

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的样子:

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 }  
    };

它如何转换为C ++?结果
更新:结果
问题:是否这是没有静态函数指针有效的答案结果?
http://www.newty.de/fpt/fpt.html#chapter2

也可以我定义不同类型的成员函数指针数组?

also can i define Array of different types of member function pointer?

推荐答案

C语言嵌入C ++,所以你没有做任何事情。然而,C ++更丰富,这就是为什么写在C code可以用C来更好++有时。你的情况,你可以定义一个类,并插入一个'[]'运算符来获得函数指针,你的情况。

The C language is embedded in C++, so you do not have to do anything. However, C++ is richer, and this is why the code written in C can be written nicer in C++ sometimes. In your case you could define a class, and insert a '[]' operator to get pointers to functions, in your case.

这篇关于转换C函数数组C ++函数指针数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆