Wednesday, March 24, 2010

Pop_back function

// pop_back - remove an item from the end of the container
int main() {

vector < int > v;
v.push_back(5); v.push_back(1);
cout << "size = " << v.size()<< endl; // return size

v.push_back(3); v.push_back(7);
v.push_back(4);
cout << "size = " << v.size()<< endl;

v.pop_back(); v.pop_back();
cout << "size = " << v.size()<< endl;

for (int i=0;i cout << v[i] << " "; cout << endl;

}

No comments:

Post a Comment