+ operator

The error is in line 80 with + operator. I don't understand why.

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
  #include<iostream>
#include<cstdlib>
#include<ctime>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<iterator>

using namespace std;

string lotto(vector<int> l) {
	vector<int> Loto(10);
	int vec_index = 0;
	/*cout << "Bitte geben Sie 6 Zahlen zwischen 1 und 49 ein.\n";
	string Tiger;
	getline(cin, Tiger);
	char Go[1000] = "";
	int j = 0;
	for (int i = 0; i < Tiger.length(); i++) {
		if (Tiger[i] != ' ') {
			Go[j] = Tiger[i];
			j++;
		}
		if (Tiger[i] == ' ' || i == Tiger.length() - 1) {
			Loto[vec_index] = atoi(Go);
			vec_index++;
			Go[0] = '\0';
			j = 0;
		}
	}*/
	//cout << vec_index;
	for (int i = 0; i <= 6; i++) {
		cin >> Loto[i];
		vec_index = i;
	}
	if (vec_index != 6) {
		cout << "Es muessen 6 Zahlen uebergeben werden.\n";
	}
	for (int i = 0; i < vec_index - 1; i++) {
		for (int j = 0; j <= vec_index - i - 2; j++) {
			if (Loto[i] == Loto[i + j + 1]) {

				cout << "Es muessen keine doppelten Zahlen vorkommen.\n";
			}
		}
	}
	for (int i = 0; i < vec_index; i++) {
		if (Loto[i] > 49 || Loto[i] < 1) {
			cout << "Die Zahlen muessen zwischen 1 und 49 liegen.";
		}
	}
	vector<int> loto_gen(6);
	srand((unsigned)time(NULL));
	//int a = rand() % 49 + 1;
	for (int i = 0; i < 6; i++) {
		loto_gen[i] = rand() % 49 + 1;
	}
	sort(loto_gen.begin(), loto_gen.begin() + 6);
	sort(Loto.begin(),Loto.begin() + 6);
	vector <int>loto_win(6);
	int jw = 0;
	for (int i = 0; i < 6; i++) {
		if (loto_gen[i] == Loto[i]) {
			loto_win[jw] = loto_gen[i];
			jw++;
}
	}
	ostringstream c;
	copy(loto_win.begin(), loto_win.end() - 1,ostream_iterator<int>(c, ", "));

	
	c << loto_win.back();
	ostringstream p;
	copy(loto_gen.begin(), loto_gen.end() - 1, ostream_iterator<int>(p, ", "));


	p << loto_gen.back();
	//string gewinn_zahl = to_string(int jw);
	string loesung_lottery = "Du hast " + to_string(jw) + " richtige: ("+c+") von (" +p+ ")";
	
	
	/*cout << "Du hast " << jw << " richtige: (";
	for (int i= 0; i < jw; i++) {
		if (i == jw - 1) {
			cout << loto_win[i];
		}
		else {
			cout << loto_win[i] << ",";

		}

	}
	cout << ") von (";
	for (int i = 0; i < 6; i++) {
		if (i == 5) {
			cout << loto_gen[i];
		}
		else {
			cout << loto_gen[i] << ",";
		}

	}
	cout << ")";
	system("pause");*/
	return loesung_lottery;
	
	
	
}


 
	
	

	int main() {
		cout << "Hausaufgabe Nr. 2, Gruppenmitglieder: Parth Patel(385321),Yogesh Rao(388949),Nina Schnier.\n";
	string lotto(vector<int> l);
	cout << lotto;
	

	
	

	return 0;
}
This is the error message(German)
1>------ Erstellen gestartet: Projekt: Project4, Konfiguration: Debug Win32 ------
1>group38_task5.cpp
1>C:\Users\User\source\repos\Project4\Project4\group38_task5.cpp(80): error C2676: Binärer Operator "+": "std::basic_string<char,std::char_traits<char>,std::allocator<char>>" definiert diesen Operator oder eine Konvertierung in einen für den vordefinierten Operator geeigneten Typ nicht
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(423,5): error MSB6006: "CL.exe" wurde mit dem Code 2 beendet.
1>Die Erstellung des Projekts "Project4.vcxproj" ist abgeschlossen -- FEHLER.
========== Erstellen: 0 erfolgreich, 1 fehlerhaft, 0 aktuell, 0 übersprungen ==========
English:
"std :: basic_string <char, std :: char_traits <char>, std :: allocator <char >>" does not define this operator or a conversion to a type appropriate to the predefined operator
c and p are not strings; they are stringstreams.

1
2
// string loesung_lottery = "Du hast " + to_string(jw) + " richtige: ("+c+") von (" +p+ ")";
string loesung_lottery = "Du hast " + to_string(jw) + " richtige: (" + c.str() +") von (" + p.str() + ")";
Topic archived. No new replies allowed.