Pop function in c++

In python there’s a pop() for list… how can I implement same in c++ using in-built funcn. or STL algo.

hello @prerak_semwal

there is pop_back function supported by the vector class.
it will pop out the last element from the vector (same as the pop function of python)

@aman212yadav

consider:
string s;
s=“hello”;

I want to pop ‘e’ out of s. How can i?

I tried s.erase(1,1)…but it erased ‘l’ adjacent to ‘e’ also

Also in python we can give specific index needed to be popped out

s.erase(1,1) is correct instruction for that and it is working correclty.
check here-> https://ide.codingblocks.com/s/443340

we cant do that in pop back function, using erase is the only option

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.