Hi,

I am new at CPP.
I am trying to create a list using STL.

I was looking at the pop_back() method, and it says that it delete the element from the list and also calls it's destructor.

so

myelement = list.back();
i can access it.
list.pop_back() will delete the object itself?

I dont want to delete the object itself, i just want to remove the object from the list.
there is a remove method also, but looks like it also calls the destructor.

So is there any way to just to remove the object from the list.

Any suggestion will be appreciated.

Thanks.

pop_back() delete last element from the list, so it doesn't delete your list. This method doesn't call list destructor, just destructor of last element in the list.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.