开发者

Why so many errors here in typedef?

from this:

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

    #ifndef _IGraphElem开发者_StackOverflow中文版ent_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:

  • Name binding and dependent names (C++ only)
  • Dependent Names (scroll down and read this section - better if you read the complete article)


  • You need a typename as mentioned by others (read this for more details).
  • You forgot ; in InitGet method after dataElement = DataElement.
  • You miss some headers, GraphItemMutex, GraphItemMutexConditionVariable and GraphWorker objects.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜