我有几个向量被保存在一个向量中。我必须对它们进行某些逻辑操作,如果操作成功完成,我必须存储保存在 arrayOfUsers 中的向量。问题是我无法访问存储在 arrayOfusers 中的特定向量
示例:arrayOfUsers 内部存储了 3 个向量,在它通过逻辑操作后,我必须将向量编号 2 写入文件中。我无法通过 arrayOfUsers 中的索引直接访问向量
vector<string> usersA ("smith","peter");
vector<string> usersB ("bill","jack");
vector<string> usersC ("emma","ashley");
vector<vector<string>> arrayOfUsers;
arrayOfUsers.push_back(usersA);
arrayOfUsers.push_back(usersB);
arrayOfUsers.push_back(usersC);
我运行循环
for ( auto x=arrayOfUsers.begin(); x!=arrayOfUsers.end(); ++x)
{
for (auto y=x->begin(); y!=x->end(); ++y)
{
//logic operations
}
if(logicOperationPassed== true)
{
// i cannot access the vector here, which is being pointed by y
//write to file the vector which passed its logic operation
// i cannot access x which is pointed to the arrayOfUsers
// ASSUMING that the operations have just passed on vector index 2,
//I cannot access it here so to write it on a file, if i dont write
//it here, it will perform the operations on vector 3
}
}