how to resize a vector

void bag::add(BAG_ELEMENT_TYPE newElement)
{
if (my_size == my_capacity)
{
my_element.resize(2 * my_capacity);
}

my_element[my_size] = newElement;
my_size++;
}

you will need to statements, one to increase the value stored in my_capacity and then the 2nd to resize the vector.
my_element.push_back( newElement );
Topic archived. No new replies allowed.