다음은이 example입니다. 내가 컴파일 할 때, 그것은 오류 반환 : I 클래스비 정적 멤버 함수 C++의 잘못된 사용
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
};
에서 void on();
에 static
을 추가하려고
void(Machine:: *ptrs[])() =
{
Machine::off, Machine::on
};
라인에
Invalid use of non-static member function
를하지만 불평
그Invalid use of member Machine::current in static member function
이 문제를 해결하도록 도와 줄 수 있습니까?
Ah, oui. 그것은 효과가 있지만 왜 설명해 주시겠습니까? 감사합니다 – GAVD
@GAVD 설명이 추가되었습니다. – songyuanyao
@songyuanyao pcap 라이브러리의 pcap_loop()도 비슷한 오류를 발생시킵니다. 이걸 보시고 당신이 어떤 생각을 갖고 있는지 알려주시겠습니까? Tqvm http://stackoverflow.com/questions/43108998/c-pcap-loop-arguments-issue – Wei