次のヘッダーファイルについて考えてみます。
template <typename T> struct tNode
{
T Data; //the data contained within this node
list<tNode<T>*> SubNodes; //a list of tNodes pointers under this tNode
tNode(const T& theData)
//PRE: theData is initialized
//POST: this->data == theData and this->SubNodes have an initial capacity
// equal to INIT_CAPACITY, it is set to the head of SubNodes
{
this->Data = theData;
SubNodes(INIT_CAPACITY); //INIT_CAPACITY is 10
}
};
次に、別のファイルのコード行について考えてみます。
list<tNode<T>*>::iterator it(); //iterate through the SubNodes
コンパイラは私にこのエラーメッセージを出します:Tree.h:38:17: error: need ‘typename’ before ‘std::list<tNode<T>*>::iterator’ because ‘std::list<tNode<T>*>’ is a dependent scope
なぜコンパイラがこれを私に怒鳴っているのか私にはわかりません。