我有几个向量被保存在一个向量中。我必须对它们执行某些逻辑操作,如果操作成功完成,我必须存储保存在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循环
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
}
}
因为它的内部为for循环 – meWantToLearn
当'logicOperationPassed'变为'true'保存值'y'在另一个变量的内部for循环 – P0W