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クラスでnumdetectionsを定義しました。私はGTOADVメンバ関数でそれを使用しています。 – vigs1990
コードを投稿してください... –