void resizeint newsize ifnewsize thecapacity reservenewsize )thesize newsizevoid reserveint newcapacity ifnewcapacity thesize returnobject *newarray new objectnewcapacity ]forint thesize++ newarrayk std::moveobjectsk )thecapacity newcapacitystd::swapobjectsnewarray )delete newarrayfigure (continuedthe resize routine is shown at lines to the code simply sets the thesize data memberafter possibly expanding the capacity expanding capacity is very expensive so if the capacity is expandedit is made twice as large as the size to avoid having to change the capacity again unless the size increases dramatically (the + is used in case the size is expanding capacity is done by the reserve routineshown at lines to it consists of allocation of new array at line moving the old contents at lines and and the reclaiming of the old array at line as shown at lines and the reserve routine can also be used to shrink the underlying arraybut only if the specified new capacity is at least as large as the size if it isn'tthe reserve request is ignored the two versions of operator[are trivial (and in fact very similar to the implementations of operator[in the matrix class in section and are shown in lines to error checking is easily added by making sure that index is in the range to size()- inclusiveand throwing an exception if it is not host of short routinesnamelyemptysizecapacitypush_backpop_backand backare implemented in lines to at lines and we see the use of the postfix +operatorwhich uses thesize to index the array and then increases thesize we saw the same idiom when discussing iterators*itr+uses itr to decide which item to view and then advances itr the positioning of the +mattersin the prefix +operator*++itr advances itr and then uses the new itr to decide which item to viewand likewiseobjects[++thesizewould increment thesize and use the new value to index the array (which is not what we would wantpop_back and back could both benefit from error checks in which an exception is thrown if the size is