Bonjour
J'ai besoin d'utiliser une map de map mais j'ai bcp de soucis à la compilation; avec l'itérateur de map< string, map<string, vector<float> > >, et aussi pour accéder aux éléments du vector<float>>...
Voici mon code:
J'obtiens les erreurs suivantes:
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49 #include <fstream> #include <string> #include <iostream> #include <map> #include <vector> #include <stdio.h> #include <algorithm> #include <iterator> using namespace std; vector<float> notes; vector<string> noms; vector<string> matieres; typedef map < string, vector<float> > mapstrvect; typedef map < string, mapstrvect > Nom_Notes_mat; string nom; string matiere; float note; int s = sizeof(matieres); int t = sizeof(noms); vector< vector<float> > synthese((s+1)*(t+1)); void afficher_synthese() { map<string,mapstrvect>::iterator itn=Nom_Notes_mat.begin(); for(;itn!= Nom_Notes_mat.end();++itn){ if ( (*itn).first == ((*(itn++)).first) && ((*itn).second).first == (((*(itn++)).second))).first)) ((*itn).second).push_back( ( (*itn++).second ).second ); Nom_Notes_mat.erase(itn++);} for(int j=0;j<t+1;++j){ for(int i=0;i<s;++i){ vector<float> v1 = (Nom_Notes_mat[matieres[j]])[noms[i]]; int size = s*t; string mat = matieres[j]; string name = noms[i]; int l = 0; float sum; for (int k=0; k<size; k++){ sum = sum+ ((Nom_Notes_mat[mat])[name])[k]; l++;} float moy = sum/l; } } }
pourtant la syntaxe de déclaration de l'itérateur itn est bonne!!!!In function ‘void afficher_synthese()’:
forum.cpp:32:53: error: expected primary-expression before ‘.’ token
forum.cpp:33:27: error: expected primary-expression before ‘.’ token
forum.cpp:34:64: error: ‘class std::map<std::basic_string<char>, std::vector<float> >’ has no member named ‘first’
forum.cpp:34:95: error: expected primary-expression before ‘.' token
forum.cpp:36:18: error: expected unqualified-id before ‘.’ token
forum.cpp:40:50: error: size of array has non-integral type ‘std::basic_string<char>’
forum.cpp:40:50: error: size of array has non-integral type ‘std::basic_string<char>’
forum.cpp:40:38: error: expected primary-expression before ‘[’ token
forum.cpp:48:37: error: size of array has non-integral type ‘std::string’
forum.cpp:48:37: error: size of array has non-integral type ‘std::string’
forum.cpp:48:33: error: expected primary-expression before ‘[’ token
et je ne comprend pas la signification du message d'erreur size of array has non-integral type std::basic_string<char>bref si quelqu'un pourrait m'aider, parce que là je vois pas du tout !
merci beaucoup
Partager