G
G
granatlime2016-03-16 22:56:02
C++ / C#
granatlime, 2016-03-16 22:56:02

How exactly does this list constructor work?

What is the result of the given string, a list in which each element is a vector?
list<vector<string>> lvs;
And how to access the elements, in this case?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MiiNiPaa, 2016-03-16
@granatlime

What is the result of this line

Empty list. For something to be there, something must be put there.
To the first / last - through front / back. To the rest - through iterators.
Example:
list<vector<string>> lvs {{"Hello", "World"}, {"Goodbye", "Universe"}, {"What", "am", "I", "doing"}};
for(auto it = list.cbegin(), it != list.cend(), ++it) {//Проходимся по всем элементам списка
    cout << (*it)[1] << '\n';
    // (*it) даст элемент списка: vector<string>
    // Пы можем обратиться к элементу вектора при помощи оператора []
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question