J'ai un probleme de creation de mon propre container a base de STL

Signaler
Messages postés
8
Date d'inscription
lundi 5 décembre 2005
Statut
Membre
Dernière intervention
1 mars 2010
-
Messages postés
3874
Date d'inscription
mardi 8 mars 2005
Statut
Modérateur
Dernière intervention
7 novembre 2014
-
J'ai un probleme, j'ai a creer son propre container mais a base de STL, avec l'algorithme que j'ai utilise on me donne des erreurs de compilation (Visual C++ 6.0). Aidez-moi a resourdre ce probleme.
 Ca c'est l'agorithme utilise,
#include
#include <list>
#include <string>
usingnamespace std;

template<class T>
class Ring {
list<T> lst;
public:
// Declaration necessary so the following
// 'friend' statement sees this 'iterator'
// instead of std::iterator:
class iterator;
friendclass iterator;
class iterator : public std::iterator<
std::bidirectional_iterator_tag,T,ptrdiff_t>{
list<T>::iterator it;
list<T>* r;
public:
// "typename" necessary to resolve nesting:
iterator(list<T>& lst,
consttypename list<T>::iterator& i)
: r(&lst), it(i) {}
booloperator==(const iterator& x) const {
return it == x.it;
}
booloperator!=(const iterator& x) const {
return !(*this == x);
}
list<T>::reference operator*() const {
return *it;
}
iterator& operator++() {
++it;
if(it == r->end())
it = r->begin();
return *this;
}
iterator operator++(int) {
iterator tmp = *this;
++*this;
return tmp;
}
iterator& operator--() {
if(it == r->begin())
it = r->end();
--it;
return *this;
}
iterator operator--(int) {
iterator tmp = *this;
--*this;
return tmp;
}
iterator insert(const T& x){
return iterator(*r, r->insert(it, x));
}
iterator erase() {
return iterator(*r, r->erase(it));
}
};
void push_back(const T& x) {
lst.push_back(x);
}
iterator begin() {
return iterator(lst, lst.begin());
}
int size() { return lst.size(); }
};

et voila les erreurs q'on me etourne:

--------------------Configuration: test - Win32 Debug--------------------
Compiling...
dfd.cpp
E:\aec\test\dfd.cpp(10) : error C2143: syntax error : missing ';' before '<'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(10) : error C2501: 'list' : missing storage-class or type specifiers
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(10) : error C2059: syntax error : '<'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(10) : error C2238: unexpected token(s) preceding ';'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(17) : error C2039: 'iterator' : is not a member of 'std'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(17) : error C2504: 'iterator' : base class undefined
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(17) : error C2143: syntax error : missing ',' before '<'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(17) : error C2059: syntax error : '<'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(18) : error C2039: 'bidirectional_iterator_tag' : is not a member of 'std'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(19) : error C2143: syntax error : missing ';' before '<'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(19) : error C2501: 'list' : missing storage-class or type specifiers
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(19) : error C2059: syntax error : '<'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(19) : error C2039: 'iterator' : is not a member of '`global namespace''
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(19) : error C2238: unexpected token(s) preceding ';'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(20) : error C2143: syntax error : missing ';' before '<'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(20) : error C2501: 'list' : missing storage-class or type specifiers
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(20) : error C2059: syntax error : '<'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(20) : error C2238: unexpected token(s) preceding ';'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(24) : error C2039: 'iterator' : is not a member of '`global namespace''
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(23) : error C2629: unexpected 'class Ring<T>::iterator ('
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(23) : error C2334: unexpected token(s) preceding ':'; skipping apparent function body
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(32) : error C2143: syntax error : missing ';' before '<'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(32) : error C2501: 'list' : missing storage-class or type specifiers
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(32) : error C2059: syntax error : '<'
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(32) : error C2039: 'reference' : is not a member of '`global namespace''
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
E:\aec\test\dfd.cpp(32) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
        E:\aec\test\dfd.cpp(71) : see reference to class template instantiation 'Ring<T>' being compiled
Error executing cl.exe.

test.exe - 26 error(s), 0 warning(s)

1 réponse

Messages postés
3874
Date d'inscription
mardi 8 mars 2005
Statut
Modérateur
Dernière intervention
7 novembre 2014
11
Ah tiens...

Tu aurais pu poster le message suivant ici...