【问题标题】:iterator for strings in array数组中字符串的迭代器
【发布时间】:2012-01-06 02:02:06
【问题描述】:

我有以下情况

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 
   }

【问题讨论】:

  • 您收到的错误信息是什么?你能给出一个最小的测试用例吗?我的编译器(g++4.5.2)没有抱怨。

标签: c++ arrays string iterator


【解决方案1】:

你试过了吗

func(*(itr[d]));

取消引用运算符优先于索引运算符。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多