클래스 이름이 GTAODV
인 정적 멤버 배열을 만들었습니다.C++의 정적 멤버 배열
gtaodv/gtaodv.o: In function `GTAODV::command(int, char const* const*)':
gtaodv.cc:(.text+0xbe): undefined reference to `GTAODV::numdetections'
gtaodv.cc:(.text+0xcc): undefined reference to `GTAODV::numdetections'
gtaodv/gtaodv.o: In function `GTAODV::check_malicious(GTAODV_Neighbor*)':
gtaodv.cc:(.text+0x326c): undefined reference to `GTAODV::numdetections'
gtaodv.cc:(.text+0x3276): undefined reference to `GTAODV::numdetections'
collect2: ld returned 1 exit status
왜이 작업을 수행 : 나는, 클래스 방법 (아래 예) 내에서
numdetections[nb->nb_addr]++;
for(int i=0; i<MAXNODES; i++) if (numdetections[i] != 0) printf("Number of detections of %d = %d\n", i, numdetections[i]);
를이 배열에 액세스 할 때
static int numdetections[MAXNODES];
그러나, 링커는 컴파일시 에러를 제공합니다 우연히 있다?
링커가'numdetections'의 정의를 알지 못하기 때문에. 이 변수를 어디에서 사용하고 있습니까? 정의는 어디에 있습니까? –
GTAODV 클래스에서 numdetection을 정의했으며 GTOADV 멤버 함수에서 사용하고 있습니다. – vigs1990
코드를 게시하십시오 ... –