Advertisement
czlowiekzgon

Untitled

Nov 8th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. void add(Gang **&ptr, int &size, int where = -1) {
  2.  
  3.  
  4. Gang **sup_ptr = new Gang *[size + 1];
  5.  
  6. for (int i = 0; i < size + 1; i++) {
  7. //sup_ptr[i] = new Gang; tu blad
  8. if (i == where) {
  9. sup_ptr[i] = new Gang(); tak chyba powino byc
  10. sup_ptr[i]->init();
  11. }
  12. else if (i > where && where >= 0) {
  13. sup_ptr[i] = ptr[i - 1];
  14. }
  15. else if (i == size && where < 0) {
  16. sup_ptr[i]->init();
  17. }
  18. else {
  19. sup_ptr[i] = ptr[i];
  20. }
  21.  
  22. }
  23.  
  24.  
  25. delete[] ptr;
  26. ptr = sup_ptr;
  27. ++size;
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement