vector_pro::pop¶
Pop and return the last element¶
Return a copy of the last element ( Not a reference ) in the vector after destroying, effectively reducing the container size by one.
See also vector_pro::pop_back()
Please note that calling this function on an empty container will get an
exception.It is not highly recommended to use this function; it has been implemented to be useful only in certain situations.
Parameters¶
none
Return value¶
A copy of the last element ( Not a reference ).
Example¶
C++
// vector_pro::pop
#include <iostream>
#include "vector_pro.h"
/**
* Output:
* 300
* 200
* 100
*/
int main ()
{
vector_pro<int> myvector;
myvector.push_back (100);
myvector.push_back (200);
myvector.push_back (300);
std::cout << myvector.pop() << '\n';
std::cout << myvector.pop() << '\n';
std::cout << myvector.pop() << '\n';
return 0;
}
Complexity¶
Constant.