#include #include using namespace stdint mainvector squares )forint squares size)++ squaresi iforint squares size)++ cout < <<squaresi <endlreturn figure using the vector classstores squares and outputs them vector and string the +standard defines two classesthe vector and string vector is intended to replace the built-in +arraywhich causes no end of trouble the problem with the built-in +array is that it does not behave like first-class object for instancebuilt-in arrays cannot be copied with = built-in array does not remember how many items it can storeand its indexing operator does not check that the index is valid the built-in string is simply an array of charactersand thus has the liabilities of arrays plus few more for instance=does not correctly compare two built-in strings the vector and string classes in the stl treat arrays and strings as first-class objects vector knows how large it is two string objects can be compared with ==<and so on both vector and string can be copied with if possibleyou should avoid using the built-in +array and string we discuss the built-in array in in the context of showing how vector can be implemented vector and string are easy to use the code in figure creates vector that stores one hundred perfect squares and outputs them notice also that size is method that returns the size of the vector nice feature of the vector that we explore in is that it is easy to change its size in many casesthe initial size is and the vector grows as needed +has long allowed initialization of built-in +arraysint daysinmonth }it was annoying that this syntax was not legal for vectors in older ++vectors were either initialized with size or possibly by specifying size sofor instancewe would write