Problème de map avec paramètre template
Bonjour, j'ai un problème que je ne comprends pas, voici le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
#include <map>
using namespace std;
template<class Type>
class Test {
public:
void bidon() {
map<int,int>::iterator it1; // OK
map<int, Type*>::iterator it2; // Plante à cause du paramètre Type*
}
};
int main(int argc, char** argv) {
Test<int> test;
test.bidon();
return 0;
} |
Le problème est que mon compilateur ne veux pas de la déclaration du deuxième itérateur. Apparemment celà viendrait du type template (Type*), pourquoi ? Comment résoudre ce problème ?
Voici les erreurs que mon compilateur me renvoi:
Citation:
g++ main.cpp -o test
main.cpp: In member function 'void Test<Type>::bidon()':
main.cpp:16: error: expected `;' before 'it2'
main.cpp: In member function 'void Test<Type>::bidon() [with Type = int]':
main.cpp:25: instantiated from here
main.cpp:16: error: dependent-name 'std::map<int,Type*,std::less<int>,std::allocator<std::pair<const int, Type*> > >::iterator' is parsed as a non-type, but instantiation yields a type
main.cpp:16: note: say 'typename std::map<int,Type*,std::less<int>,std::allocator<std::pair<const int, Type*> > >::iterator' if a type is meant
Savez-vous comment résoudre celà ?
Merci.
Bouba