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
;
inInitGet
method afterdataElement = DataElement
. - You miss some headers,
GraphItemMutex
,GraphItemMutexConditionVariable
andGraphWorker
objects.
精彩评论