我正在关注这个example。但是,当我编译,它会返回一个错误:非静态成员函数的使用无效C++
Invalid use of non-static member function
在该行
void(Machine:: *ptrs[])() =
{
Machine::off, Machine::on
};
我试图在类
class Machine
{
class State *current;
public:
Machine();
void setCurrent(State *s)
{
current = s;
}
static void on(); // I add static here ...
static void off(); // and here
};
添加static
到void on();
但抱怨
Invalid use of member Machine::current in static member function
你能帮我解决这个问题吗?
啊,oui。它的工作原理,但你能解释为什么吗?谢谢 – GAVD
@GAVD解释添加。 – songyuanyao
@songyuanyao pcap库下的pcap_loop()会抛出类似的错误。请你看看这个,让我知道你有什么想法吗? Tqvm 0http://stackoverflow.com/questions/43108998/c-pcap-loop-arguments-issue – Wei