2011-11-25 160 views
1

字符串我有以下情況迭代器陣列

typedef std::array<std::array<string,9>,9>candidates; 
std::vector<candidates>cand; 

我需要遍歷字符串遞歸的深度,並希望他們即使調整大小不變。我該怎麼做?我以前使用的迭代器在重新調整尺寸時會失效,我想要一種解決方法..這是以前的嘗試。

for(itr[d] = cand[d][i][j].begin(); itr[d] !=cand[d][i][j].end(); ++itr[d]) 
    { 
    //if condition met - proceed to recursive call 

    //else reset (using ppp and push) and proceed to next element of string 
    } 
+0

你得到的錯誤信息是什麼?你能給一個最小的測試用例嗎?我的編譯器(g ++ 4.5.2)沒有投訴它。 – fefe

回答

1

你試過

func(*(itr[d])); 

反引用運算符的優先級高於索引操作。

+0

不..等待..這個問題似乎解決了。 –