title: cpp empty array declaration
body: <p>Hello I have the following test code and I am confused about cpp.</p>
  
  <ol>
  <li><p>If you declare in library.h an array with an empty element clause .. what will the compiler pick? It does also not complain, I use Cygwin.</p></li>
  <li><p>In library.cpp I assign values to two elements, is the compiler assuming an array with one element and I write the second element outside the scope of the array?</p></li>
  </ol>
  
  <h3>library.h</h3>
  
  <pre><code>#ifndef LIBRARY_H
  #define LIBRARY_H
  
  class library {
  
  public:
      void print();
      char a[];
  };
  
  #endif
  </code></pre>
  
  <h3>library.cpp</h3>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include "library.h"
  
  void library::print() {
      a[0] = 'a';
      printf("1. element: %d\n", a[0]);
      a[1] = 'b';
      printf("2. element: %d\n", a[1]);
  }
  </code></pre>
  
  <h3>client.cpp</h3>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include "library.h"
  
  void execute();
  library l;
  
  int main() {
      l = library();
      l.print();
      return 0;
  }
  </code></pre>
  
  <h3>Makefile</h3>
  
  <pre><code>OPTIONS=-Wall
  
  all: main
  
  run: main
          ./main.exe
  
  main: client.o library.o
          g++ $(OPTIONS) -o main $^
  
  library.o: library.cpp library.h
          g++ $(OPTIONS) -c $&lt;
  
  .cpp.o:
          g++ $(OPTIONS) -c $&lt;
  
  clean:
          rm -r *.o
  </code></pre>