Bonjour,

J'ai un warning à la compilation de ce fichier

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
// STL
#include <string>
// structures de données et algorithmes
#include <vector>
// Flux
#include <iostream>
 
using namespace std;
 
 
template<typename T>
void affiche(const vector<T> & vect, const string & sep);
 
int main()
{
	vector<int> v(10);
	affiche(v, " & ");
	return 0;
}
 
 
template<typename type>
void affiche(const vector<type> & vect, const string & sep)
{
	vector<type>::const_iterator it, ideb, ifin;
	ideb = vect.begin();
	ifin = vect.end();
 
	for(it = ideb; it != ifin; ++it)
		cout << *it << sep;
	cout << endl;
}
à la compilation, gcc me donne (avec les options -Wall -ansi -pedantic)

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
Main2.cpp: In function `void affiche(const std::vector<T,
   std::allocator<_CharT> >&, const std::string&)':
Main2.cpp:36: error: syntax error before `,' token
Main2.cpp: In function `void affiche(const std::vector<T,
   std::allocator<_CharT> >&, const std::string&) [with T = int]':
Main2.cpp:28:   instantiated from here
Main2.cpp:37: error: `ideb' undeclared (first use this function)
Main2.cpp:37: error: (Each undeclared identifier is reported only once for each
 
   function it appears in.)
Main2.cpp:28:   instantiated from here
Main2.cpp:38: error: `ifin' undeclared (first use this function)
Main2.cpp:40: error: `it' undeclared (first use this function)
Si j'enlève le -pedantic, il ne reste plus que des warnings... mais j'aimerais savoir pourquoi.



Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
Main2.cpp: In function `void affiche(const std::vector<T,
   std::allocator<_CharT> >&, const std::string&)':
Main2.cpp:36: warning: `std::vector<T, std::allocator<_CharT> >::const_iterator
   ' is implicitly a typename
Main2.cpp:36: warning: implicit typename is deprecated, please see the
   documentation for details
Main2.cpp:36: warning: `std::vector<T, std::allocator<_CharT> >::const_iterator
   ' is implicitly a typename
Main2.cpp:36: warning: implicit typename is deprecated, please see the
   documentation for details
Main2.cpp:36: warning: `std::vector<T, std::allocator<_CharT> >::const_iterator
   ' is implicitly a typename
Main2.cpp:36: warning: implicit typename is deprecated, please see the
   documentation for details
J'en perd mon latin....