Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string* allocateAndCopyToNewArray( string* pOldArray, int oldNumEntries, int newCapacity )
- {
- string* str = new string[newCapacity];
- if(newCapacity > oldNumEntries)
- {
- std::copy(mWords, mWords+oldNumEntries, str);
- }
- else
- {
- std::copy(mWords, mWords+newCapacity, str);
- }
- return str;
- }
- void DynamicArray::resize( int newCapacity )
- {
- string *str = allocateAndCopyToNewArray(mWords, mNumWords, newCapacity);
- delete [] mWords;
- mCapacity = newCapacity;
- mWords = str;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement