: Problèmes de templates avec la STL [C++] - Programmation
Marsh Posté le 11-01-2002 à 00:32:46
Au cas où voilà ce que le compilo me jette:
/usr/include/g++-3/stl_iterator.h: In instantiation of `iterator_traits<int>':
/usr/include/g++-3/stl_iterator.h:574: instantiated from `reverse_iterator<int>'
test.cpp:10: instantiated from `A<int>'
test.cpp:25: instantiated from here
/usr/include/g++-3/stl_iterator.h:102: `int' is not a class, struct, or union type
/usr/include/g++-3/stl_iterator.h:103: `int' is not a class, struct, or union type
/usr/include/g++-3/stl_iterator.h:104: `int' is not a class, struct, or union type
/usr/include/g++-3/stl_iterator.h:105: `int' is not a class, struct, or union type
/usr/include/g++-3/stl_iterator.h:106: `int' is not a class, struct, or union type
/usr/include/g++-3/stl_iterator.h: In instantiation of `reverse_iterator<int>':
test.cpp:10: instantiated from `A<int>'
test.cpp:25: instantiated from here
/usr/include/g++-3/stl_iterator.h:574: no type named `iterator_category' in `struct iterator_traits<int>'
/usr/include/g++-3/stl_iterator.h:576: no type named `value_type' in `struct iterator_traits<int>'
/usr/include/g++-3/stl_iterator.h:578: no type named `difference_type' in `struct iterator_traits<int>'
/usr/include/g++-3/stl_iterator.h:580: no type named `pointer' in `struct iterator_traits<int>'
/usr/include/g++-3/stl_iterator.h:582: no type named `reference' in `struct iterator_traits<int>'
/usr/include/g++-3/stl_iterator.h:599: no type named `reference' in `struct iterator_traits<int>'
/usr/include/g++-3/stl_iterator.h:604: no type named `pointer' in `struct iterator_traits<int>'
/usr/include/g++-3/stl_iterator.h:626: no type named `difference_type' in `struct iterator_traits<int>'
/usr/include/g++-3/stl_iterator.h:629: no type named `difference_type' in `struct iterator_traits<int>'
/usr/include/g++-3/stl_iterator.h:633: no type named `difference_type' in `struct iterator_traits<int>'
/usr/include/g++-3/stl_iterator.h:636: no type named `difference_type' in `struct iterator_traits<int>'
/usr/include/g++-3/stl_iterator.h:640: no type named `reference' in `struct iterator_traits<int>'
Je ne comprends pas pourquoi j'aides erreurs de la STL. Rien de suffisamment clair sur ce que j'ai codé.
Et si je remplace A<int> par A<string> ça donne:
/usr/include/g++-3/stl_iterator.h: In instantiation of `iterator_traits<string>':
/usr/include/g++-3/stl_iterator.h:574: instantiated from `reverse_iterator<string>'
test.cpp:11: instantiated from `A<string>'
test.cpp:26: instantiated from here
/usr/include/g++-3/stl_iterator.h:102: no type named `iterator_category' in `class string'
/usr/include/g++-3/stl_iterator.h: In instantiation of `reverse_iterator<string>':
test.cpp:11: instantiated from `A<string>'
test.cpp:26: instantiated from here
/usr/include/g++-3/stl_iterator.h:574: no type named `iterator_category' in `struct iterator_traits<string>'
[edtdd]--Message édité par Krueger--[/edtdd]
Marsh Posté le 11-01-2002 à 11:38:08
pourquoi tu ne fais pas ca?
Code :
|
LEGREG
Marsh Posté le 11-01-2002 à 21:02:33
Ah, ben oui ça marche en effet. Mais j'avais toujours préféré surcharger les opérateurs binaires voulus commutatifs par des fonctions globales...
Merci en tous cas. C'est bête, mais je n'y avait plus pensé à force d'automatiser la définition de ce genre de méthodes.
Marsh Posté le 11-01-2002 à 00:11:28
Voilà mon programme:
Donc je n'arrive pas à faire compiler tout ça. Si je n'inclus aucune en-tête STL, ça passe. Sinon si j'enlève la surcharge de l'opérateur + de la classe A ou si je la définit dans la déclaration de la classe A, ça passe aussi. Moi pas comprendre.
Merci de votre aide.
---------------
"Colère et intolérance sont les ennemis d'une bonne compréhension." Gandhi