title: How can I shift an array to the right in c++?
body: <p>I'm trying to implement a function for shifting an array of objects to the right of the array. All i found in the Internet is implementation of circular shifts but that is not what I'm looking for. I want to shift the elements to the right if theres actually empty space on its right.
  suppose you created an array of object Packet, and its of size 10</p>
  
  <pre><code>Packet* a[] = { p4 , p3 , p2 , p1, null, null, null, null, null, null }
  </code></pre>
  
  <p>the shifting function would just shift everything to the right</p>
  
  <pre><code>{ null ,p4 , p3 , p2 , p1, null, null, null, null, null }
  </code></pre>
  
  <p>and in the case of having an element at the end of the array</p>
  
  <pre><code>{ p10, p9, p8, p7 ,p6 ,p5 ,p4 , p3 , p2 , p1}
  </code></pre>
  
  <p>the function just wouldn't shift anything.</p>
  
  <pre><code> { p4 , p3 , p2 , p1, null, null, null, null, null, null }
  </code></pre>
  
  <p>my idea of implementation is to copy the array into a temp one,
  erase everything on the original array, and then copy into it but starting from position [1] and not position [0]. but this doesn't seem very efficient.</p>
  
  <p>any other ideas?</p>