does this function pop out the top value in a vector? how do i pop out the top value and store it in another variable? it doesn't work when i do this:

x = stringvector.pop_back();

Printable View

- 09-02-2002Vector Manpop_back() function in the vector class
does this function pop out the top value in a vector? how do i pop out the top value and store it in another variable? it doesn't work when i do this:

x = stringvector.pop_back(); - 09-02-2002ygfperson
how about just pop()?

- 09-02-2002Eibro
Vectors don't have a pop() function. Why not just use the [] operator? If you want the first element it'd be vectorname[0], if you want the last element it'd be vectorname[vectorname.size()];

- 09-03-2002endoRe: pop_back() function in the vector classQuote:

*Originally posted by Vector Man*

**does this function pop out the top value in a vector? how do i pop out the top value and store it in another variable? it doesn't work when i do this:**

x = stringvector.pop_back();

- 09-03-2002Troll_King
It supports and erase() method:

vector::size_type size;

size = svec.size();

svec.erase(size);

But you should also probably be using iterators to identify the type. - 09-03-2002LuckY
Some function definitions:

Code:`void pop_back();`

reference back();

const_reference back() const;

//The member function returns a reference to the last element of the controlled sequence, which must be non-empty.

here's a list of all the functions in vector:

Code:**vector**

allocator_type · assign · at · back · begin · capacity · clear ·

const_iterator · const_reference · const_reverse_iterator ·

difference_type · empty · end · erase · front · get_allocator ·

insert · iterator · max_size · operator[] · pop_back · push_back ·

rbegin · reference · rend · reserve · resize · reverse_iterator ·

size · size_type · swap · value_type · vector

http://dinkumware.com/manuals/reader...&h=vector.html - 09-03-2002Sang-draxQuote:

*Originally posted by Eibro*

**Vectors don't have a pop() function. Why not just use the [] operator? If you want the first element it'd be vectorname[0], if you want the last element it'd be vectorname[vectorname.size()];**

Code:`vectorname[vectorname.size()-1]; //Or my program is buggier than I think`

- 09-03-2002ygfpersonQuote:

*Originally posted by Eibro*

**Vectors don't have a pop() function. Why not just use the [] operator? If you want the first element it'd be vectorname[0], if you want the last element it'd be vectorname[vectorname.size()];**

- 09-03-2002EibroQuote:

*Originally posted by Sang-drax*

Code:`vectorname[vectorname.size()-1]; //Or my program is buggier than I think`