C++语法问题

标签 c++ syntax

已经很晚了,我无法弄清楚我的语法有什么问题。我问过其他人,他们也找不到语法错误,所以我在 friend 的建议下来到这里。

template <typename TT>
bool PuzzleSolver<TT>::solve ( const Clock &pz ) {

  possibConfigs_.push( pz.getInitial() );
  vector< Configuration<TT> > next_;

  //error is on next line
  map< Configuration<TT> ,Configuration<TT> >::iterator found;

  while ( !possibConfigs_.empty() && possibConfigs_.front() != pz.getGoal() ) {
    Configuration<TT> cfg = possibConfigs_.front();
    possibConfigs_.pop();
    next_ = pz.getNext( cfg );

    for ( int i = 0; i < next_.size(); i++ ) {
      found = seenConfigs_.find( next_[i] );
      if ( found != seenConfigs_.end() ) {
        possibConfigs_.push( next_[i] );
        seenConfigs_.insert( make_pair( next_[i], cfg ) );
      }
    }
  }
}

怎么了?

感谢您的帮助。

最佳答案

如果我没记错的话,这个语法是有歧义的:

map< Configuration<TT> ,Configuration<TT> >::iterator found;

试试看:

typename map< Configuration<TT> ,Configuration<TT> >::iterator found;

关于C++语法问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2597272/

相关文章:

c++ - 具有完整类型信息的循环依赖

c++ - 纹理splat opengl的最有效方法?

python - 这种无效语法是怎么来的?

c -\x 在 C/C++ 中是什么意思?

python - 将 if-elif-else 语句放在一行上?

c# - 为什么更喜欢属性而不是公共(public)变量?

Python 正则表达式重新编译说明

C++通过引用函数传递数组但内容保持不变

c++遗传算法变异错误

c++ - 从 C 到 C++ 并返回