title: Static Member Array in C++
body: <p>I've created a static member array in class named <code>GTAODV</code>.</p>
  
  <pre><code>static int numdetections[MAXNODES];
  </code></pre>
  
  <p>However, when I try to access this array within the class methods (examples below),</p>
  
  <pre><code> numdetections[nb-&gt;nb_addr]++;
   for(int i=0; i&lt;MAXNODES; i++) if (numdetections[i] != 0) printf("Number of detections of %d = %d\n", i, numdetections[i]);
  </code></pre>
  
  <p>the linker gives an error during compilation:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Why does this happen?</p>