多年来我没有使用 C/C++,我正在尝试复习基础知识,但我遇到了迭代 3D 向量的问题:
#include <string>
#include <vector>
#include <iterator>
int main() {
std::vector< std::vector<std::string> > container;
std::vector<std::string> table;
std::string line;
for (int container_it = 0; container_it < 2; container_it++) {
for (int table_it = 0; table_it < 5 ; table_it++) {
line = "TEST";
table.push_back(line);
}
container.push_back(table);
}
for (std::vector< std::vector<std::string> >::iterator container_it = container.begin(); container_it != container.end(); container_it++)
for (std::vector<std::string>::iterator it = (*container_it)->begin(); it != (*container_it)->end(); it++)
std::cout << *it << std::endl;
}
我得到错误:
base operand of ‘->’ has non-pointer type ‘std::vector<std::basic_string<char> >’
base operand of ‘->’ has non-pointer type ‘std::vector<std::basic_string<char> >’