Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How do I use the <list> library?

+3 votes
asked Aug 20, 2021 by Crazy Gamer (150 points)

I am trying to make a list in my code, but when I follow online guides I just get error messages like 

error: no matching function for call to ‘std::list >::insert(std::string&)’

What should I do?

1 Answer

+1 vote
answered Sep 22, 2021 by Peter Minarik (58,020 points)

Read the documentation.

std::list::insert() doesn't have an overload with only taking a single argument: std::string&.

You're doing something wrong.

Also, if you don't know how to use list, then probably you don't want to use list. Probably it's not even insert() that you're looking for.

If you want to have a collection of "things", you should be probably just fine using std::vector. Also, if you want to add an element to the collection, push_back() is the typical way to go.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...