title: Shortend array printing wrong result
body: <p>I would like to create shorten the size of array to cerstaind number. I have a class</p>
  
  <pre><code>class Numbers{
  public:
    Numbers(){
       max = 10;
       arr = new int[max];
       current = 0;
   }
  private:
   int *arr;
   int max;
   int current;
  }
  </code></pre>
  
  <p>What i simply want to do. If the array contains numbers (10) e.g</p>
  
  <pre><code>arr // 1 2 3 4 5 6 7 8 9 10
  </code></pre>
  
  <p>and i call <code>.shorten(number)</code> method , it will shorten array to said number , so in 6 it would be </p>
  
  <pre><code>arr // 1 2 3 4 5 6
  </code></pre>
  
  <p>I have created a method </p>
  
  <pre><code>void Numbers::shorten(int a ){
    int *tmp = new int[a];
    for( int i = 0; i &lt; a; i++){
      tmp[i] = arr[i];  
    }
    max = a;
    delete[] arr;
    arr = tmp;
  }
  </code></pre>
  
  <p>When i invoke this method , and print the array , the output should be <code>1 2 3 4 5 6</code> but instead it prints the same array with  first two numbers being some random numbers from memory. What causes this , how can i prevent this from happening? </p>
  
  <p>printing function looks like this </p>
  
  <pre><code>void Numbers::PrintAll(){
    for( int i = 0; i &lt; max ; i++){
      cout &lt;&lt; arr[i] &lt;&lt; endl;
    }
  }
  </code></pre>
  
  <p>and declaring it as</p>
  
  <pre><code>Numbers one;
  </code></pre>
  
  <p>//I know i can use STL containers but i would like to do this with arrays.</p>