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.

Problem in list operator

–2 votes
asked Apr 1, 2021 by thibault bouvier (110 points)
Good morning all

I would need a little help on the following code:

https://onlinegdb.com/H1P8jgmrd

I get the following error
error: no match for ‘operator []’ (operand types are ‘std :: list>’ and ‘int’)

if you have any ideas, thank you in advance

1 Answer

0 votes
answered Apr 9, 2021 by Peter Minarik (86,040 points)

The problem is that std::list is a linked list and as such, normally you cannot access indexed element (not in constant time anyway).

I believe what you wanted to use was std::vector instead.

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.
...