Concaténation des variables dans C++
Bonsoir;
Je voudrais concaténer des variables, voila mon code:
Code:
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
|
main(){
int nbre,i,Coef;
string Mat;
float NC1,NC2;
string tab();
string var;
//cout <<" ";
cout <<"- Donnez le nombre des matieres : ";
cin >>nbre;
for (i=1;i<=nbre;i++){
cout<<i<<" - [Nom Mat] [Coef] [Note C1] [Note C2] : ";
cin >>Mat;
cin >>Coef;
cin >>NC1;
cin >>NC2;
var+=Mat + "-" + Coef + "-" + NC1 + "-" + NC2;
}
cout <<"\n "<<var;
cin.get();
cin.get();
} |
Il me retourne:
Citation:
26 no match for 'operator+' in 'std::operator+(const std::basic_string<_CharT, _Traits, _Alloc>&, const _CharT*) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>](((const char*)"-")) + Coef'
Pouvez vous me dire ou se trouve l'erreur?
Merci d'avance.