在代碼:迭代器種類
//I know that to get this effect (being able to use it with std algorithms) I can inherit like I did in line below:
class Iterator //: public std::iterator<std::bidirectional_iterator_tag,T>
{
private:
T** itData_;
public:
//BUT I WOULD LIKE TO BE ABLE TO DO IT BY HAND AS WELL
typedef std::bidirectional_iterator_tag iterator_category;
typedef T* value_type;//SHOULD IT BE T AS value_type or T*?
typedef std::ptrdiff_t difference_type;
typedef T** pointer;//SHOULD IT BE T* AS pointer or T**?
typedef T*& reference;//SHOULD IT BE T& AS reference or T*&?
};
基本上我問的是,如果我有我喜歡的類型T **的變量在迭代器類是正確的假設值類型爲這個迭代器將是T *和就像我在代碼中的評論中所描述的那樣,就在相關的行旁邊。
謝謝。
內部數據格式不確定接口類型。外部接口,即'operator *'和'operator - >'確定接口類型。 'operator *'返回什麼? – Potatoswatter 2010-04-18 18:19:48