Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void MyDynamicArray::add(int v)
- {
- nums = nums +1;
- if (nums>capacity) //doubles when capcity is reached
- {
- //time to double
- cout << "Doubling to : " << capacity * 2 << endl;
- capacity = capacity * 2;
- }
- int *temp;
- temp = new int[capacity];
- for( int x=0; x<nums; x++) //temp array to push numbers over
- {
- temp[x] = array[x];
- }
- temp[nums-1] = v;
- delete [] array;
- array = temp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement