ListIterator
内
List
麻烦
,我不知道为什么这不工作:C++嵌套类构造函数和参数
template<class T, int length>
class List {
public:
typedef struct Row {
T data;
int prev;
int next;
} Row;
class ListIterator {
typedef ListIterator iterator;
public:
ListIterator(int mPos, Row mRow) : pos(mPos) , row(mRow){}
//methods
private:
int pos;
Row row;
};
typedef ListIterator iterator;
iterator begin() const;
private:
Row storage[length];
int startDataIdx = 0;
};
template<class T, int length>
typename List<T,length>::iterator
List<T, length>::begin() const{
iterator item_iterator(startDataIdx, storage[startDataIdx]);
return(item_iterator);
}
没有匹配功能来电 '名单:: ::的ListIterator的ListIterator(const int的&,常量行&)'
我想创建一个ListIterator<T>
其相同T
为List
作为参数(显然是因为它迭代了与List
包含的相同类型的元素),我该怎么做? 在方法begin()
中使用new
还是保持原样(不要使用新的,可能有的优点)?
每个标准库容器都有'iterator'和'const_iterator'内部类,为什么你认为它是这样? –
所以你告诉我,我不能创建一个'iterator',它有一个引用来自'list'的行? – binaryBigInt