Bonjour,
Je suis nouveau avec les STL. Est-ce que quelqu'un pourrait m'expliquer le pourquoi du second param�tre (le code complet est au bas de la page) dans:M�me chose pour le 3e param�tre dans :
Code : S�lectionner tout - Visualiser dans une fen�tre � part set<const char*, ltstr> A(a, a + sizeof(a)/sizeof(a[0]) );
Code : S�lectionner tout - Visualiser dans une fen�tre � part copy(A.begin(), A.end(), ostream_iterator<const char*, char>(cout, " ") );
Code original de Phil Ottewell's STL Course - http://www.pottsoft.com/home/stl/stl.htmlx
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 struct ltstr { bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) < 0; } }; int main( int argc, char *argv[] ) { const char* a[] = { "Gray", "Pete", "Oggy", "Philip", "JAF", "Simon", "Nick", "Elliott", "Roy", "David", "Tony", "Nigel" }; const char* b[] = { "Sandy", "John", "Andrzej", "Rob", "Phil", "Happy", "Elliott", "Roy", "David", "Tony", "Nigel" }; set<const char*, ltstr> A(a, a + sizeof(a)/sizeof(a[0]) ); set<const char*, ltstr> B(b, b + sizeof(b)/sizeof(b[0]) ); set<const char*, ltstr> C; cout << "Set A: "; copy(A.begin(), A.end(), ostream_iterator<const char*, char>(cout, " ") );
Partager