1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
template <class T>
class CMyClass
{
public:
class const_iterator;
class iterator
:public std::iterator<std::forward_iterator_tag, T>
{
public:
explicit iterator( T* el)
:it(el){}
iterator& operator++()
{
++it;
return *this;
}
iterator operator++(int) const
{
iterator t(*this);
++t;
return t;
}
bool operator==(iterator const& other) const
{return it == other.it;}
bool operator!=(iterator const& other) const
{return !(it == other.it);}
bool operator==(const_iterator const& other) const
{return it == other.it;}
bool operator!=(const_iterator const& other) const
{return !(it == other.it);}
T& operator*() const
{return *it; }
T* operator->() const
{return it; }
protected:
//pointeur sur l'élément en cours
T* it;
friend class const_iterator;
};
class const_iterator
:public std::iterator<std::forward_iterator_tag, T>
{
public:
explicit const_iterator(const T* el)
:it(el){}
const_iterator (const iterator& other)
:it(other.it){}
const_iterator& operator++()
{
++it;
return *this;
}
const_iterator operator++(int) const
{
const_iterator t(*this);
++t;
return t;
}
bool operator==(const_iterator const& other) const
{return it == other.it;}
bool operator!=(const_iterator const& other) const
{return !(it == other.it);}
const T& operator*() const
{return *it; }
const T* operator->() const
{return it; }
protected:
//pointeur sur l'élément en cours
const T* it;
friend class iterator;
};
error C2039: 'it'*: n'est pas membre de 'std::iterator<_Category,_Ty>'
1> with
1> [
1> _Category=std::forward_iterator_tag,
1> _Ty=slope_t
1> ]
1> d:\HOME\MyClass.h(161)*: lors de la compilation de la fonction membre '<Inconnu>' de la classe <Inconnu>
1> .\HOME\MyClass.cpp(899)*: voir la référence à l'instanciation de la classe modèle 'MyNameSpace::CMyClass<T>::const_iterator' en cours de compilation
1> with
1> [
1> T=slope_t
1> ]
1>d:\HOME\MyClass.h(161) : fatal error C1903: impossible de récupérer à partir des erreurs précédentes*; arrêt de la compilation |
Partager