【发布时间】:2013-03-28 00:46:58
【问题描述】:
这可能是一些基本的东西,我有一个来自一个类(称为cell)的函数,标识符为woo_func_ptr,它带有一个指向void类型的函数的指针,没有参数(void (*void_ptr)(void))(我@987654326 @)。在另一个类中,我有一个cell 的对象,我使用方法woo_func_ptr。它不允许我这样做,我在上面的标题中得到了错误。如果这两个函数没有嵌入到一个类中,它们就可以正常工作
typedef void (*void_ptr)(void);
double WOO{0};
struct cell {
void woo_func_ptr(void_ptr jo)
{
jo();
}
};
class woosah
{
public:
void woo_func()
{
WOO+=rand();
std::cout << WOO << std::endl;
};
void run()
{
// other stuff
temp_cell.woo_func_ptr(woo_func);
// yet more stuff
}
cell temp_cell;
};
【问题讨论】:
标签: c++ class function pointers