我有幾個向量被保存在一個向量中。我必須對它們執行某些邏輯操作,如果操作成功完成,我必須存儲保存在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