更新时间:2022-03-18 09:23:25
您需要 typename std :: list< T> :: iterator
。这是因为 list
取决于模板参数,因此编译器不能知道它的名称迭代器
(很好,从技术上它可以知道,但C ++标准不工作这种方式)。关键字 typename
告诉编译器以下是类型的名称。
You need typename std::list<T>::iterator
. This is because list
depends on the template parameter, so the compiler cannot know what exactly is the name iterator
within it going to be (well, technically it could know, but the C++ standard doesn't work that way). The keyword typename
tells the compiler that what follows is a name of a type.