为什么有这么多的错误在这里的typedef? [英] Why so many errors here in typedef?

查看:104
本文介绍了为什么有这么多的错误在这里的typedef?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从这个:

的C

  //零部件++ 0x中STD
    #包括LT&;升压/ bind.hpp>
    #包括LT&;升压/ function.hpp>    的#ifndef _IGraphElement_h_
    #定义_IGraphElement_h_    使用命名空间std;
    模板< typename的数据类型>
    类IGraphElement:公共IGraphElementBase {        TYPEDEF的boost ::功能和LT;无效(数据类型)GT;功能;
        的typedef的std ::矢量<作用> FunctionSequence; //(*行)
        的typedef FunctionSequence:迭代FunctionIterator; //(行**)
// ...
};

我收到C2146和C4430在同一时间线上**!(如何解决这样的事情?


解决方案

 的typedef FunctionSequence:迭代FunctionIterator; //(行**)

这应该写成

 的typedef typename的FunctionSequence:迭代FunctionIterator;

由于迭代器是必需的是一个从属名称,所以类型名称

阅读从属名称的位置:

from this:

   // parts of c++0x std
    #include <boost/bind.hpp> 
    #include <boost/function.hpp>

    #ifndef _IGraphElement_h_
    #define _IGraphElement_h_

    using namespace std ;
    template <typename DataType >
    class IGraphElement : public IGraphElementBase{

        typedef boost::function<void(DataType)>   Function;
        typedef std::vector<Function>      FunctionSequence;  // (line *)
        typedef FunctionSequence::iterator FunctionIterator; // (line **)
//...
};

I get C2146 and C4430 on line ** at the same time!( How to fix such thing?

解决方案

typedef FunctionSequence::iterator FunctionIterator; // (line **)

This should be written as,

typedef typename FunctionSequence::iterator FunctionIterator;

Since iterator is a dependent name, so typename is required!

Read about dependent name here:

这篇关于为什么有这么多的错误在这里的typedef?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆