Eventuali duplicati:
C++: undefined reference to static class memberindefinito riferimento alla variabile statica
sto usando MinGW. Perché variabile statica non funziona
[Linker error] undefined reference to `A::i'
#include <windows.h>
class A {
public:
static int i;
static int init(){
i = 1;
}
};
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil){
A::i = 0;
A::init();
return 0;
}
si dovrebbe cambiare ritorno del 'init' di annullare, o restituire qualcosa –
Questa domanda è stato chiesto innumerevoli volte: http://stackoverflow.com/questions/272900/c -undefined-reference-to-static-class-member http://stackoverflow.com/questions/12117859/c-undefined-reference-to-static-variable http://stackoverflow.com/questions/3672088/undefined-reference -error-to-use-of-static-variables http://stackoverflow.com/questions/7787059/g-undefined-reference-static-member-variable e molti altri –