title: How to initialize a pointers array in c++
body: <p>I used valgrind to test my code, and found out that the problem might be with the way I initialized the pointer array. But I am not sure where the problem is.</p>
  
  <p>Here's the error:</p>
  
  <pre><code>Conditional jump or move depends on uninitialised value(s)
  
  ==7846==    at 0x41065A: Scene::drawscene() const (scene.cpp:142)
  
  ==7846==    by 0x4111C3: main (testscene.cpp:48)
  
  ==7846==  Uninitialised value was created by a heap allocation
  
  ==7846==    at 0x4C29F90: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  
  ==7846==    by 0x50C1829: operator new(unsigned long) (in /usr/lib/libc++abi.so.1.0)
  
  ==7846==    by 0x40FBE8: Scene::copy(Scene const&amp;) (scene.cpp:45)
  
  ==7846==    by 0x40FB7C: Scene::Scene(Scene const&amp;) (scene.cpp:22)
  
  ==7846==    by 0x41108E: main (testscene.cpp:41)
  
  ==7846== 
  ==7846== Conditional jump or move depends on uninitialised value(s)
  
  ==7846==    at 0x4107AB: Scene::drawscene() const (scene.cpp:149)
  
  ==7846==    by 0x4111C3: main (testscene.cpp:48)
  
  ==7846==  Uninitialised value was created by a heap allocation
  
  ==7846==    at 0x4C29F90: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
  
  ==7846==    by 0x50C1829: operator new(unsigned long) (in /usr/lib/libc++abi.so.1.0)
  ==7846==    by 0x40FBE8: Scene::copy(Scene const&amp;) (scene.cpp:45)
  ==7846==    by 0x40FB7C: Scene::Scene(Scene const&amp;) (scene.cpp:22)
  ==7846==    by 0x41108E: main (testscene.cpp:41)
  </code></pre>
  
  <p>And the way I initial the array is below:</p>
  
  <pre><code> Image** image;
      int** sequence;
      images = new Image*[max];
      sequence = new int*[max];
  </code></pre>