Advertisement
triclops200

C++Expandarraybyamount

Aug 25th, 2011
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.19 KB | None | 0 0
  1. template <class T>
  2. void ExpandArray(T *&arr, int &len, int newlen)
  3. {
  4. T temparr = new T[newlen];
  5. for(int i = 0; i < len; i++)
  6. temparr[i]=arr[i];
  7.  
  8. delete[]arr;
  9. arr = temparr;
  10. len=newlen;
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement