std::vector<Object*> colList;
void Player::addToList( Object* object ) {
colList.push_back( object );
}
int Player::getColListSize() const {
return colList.size();
}
Using raw arrays, you need to reallocate enough space to hold N+1 Object*s, and move those Object*s from the old array into the new array, and destroy the old array:
Object* newArr = new Object*[N+1]; for ( int idx = 0; idx < N; ++idx ) newArr[idx] = colList[idx]; delete[] colList; colList = newArr;
Most implementations of std::vector do the same as above behind the scenes.