-4

Like this:

list< vector < string > > ?

if the answer is yes,how I use it to print each elements of the list by For Cycle ?

Thanks everyone.I know how to print list< int >,which can be traversed by FOR CYCLE.But in fact, if I use FOR CYCLE and iterator to list< vector < string > >,I will be fail.

LWH
  • 97
  • 3
  • 11

2 Answers2

0

of course it is possible. You can use an iterator to print each element of the list, try something like that:

list<vector<string> >::iterator it;
for(it=your_list.begin();it!=your_list.end();it++)
{
    //your code to print waht you want
    //it is a pointer to a vector<string>
    //...
}
fonfonx
  • 1,475
  • 21
  • 30
0

If your compiler is up to date with the standard:

std::list<std::vector<std::string>> lst;
for ( auto& vec : lst ) // Iterate through all std::vector's
   for ( auto& str : vec ) // Iterate through all std::string's
       std::cout << str << std::endl; // str is your std::string