How to fix this ? I am encounter with string and integer.
The code line 10 : sum += week[x] .. not match for operator += because sum(int) and week(string).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#include <iostream>
usingnamespace std;
int main()
{
string week[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
int sum =0;
for (int x =0 ; x <7; x++){
sum += week[x]; // Error, not match for operator +=
cout << sum << endl;
}
}