c++ - '+' cannot add two pointers, but just printing an int and an explicit string? -
i trying utilize array maintain track of totals of different types of items (up 50 types). when want print totals out, error saying "'+' cannot add together 2 pointers." i'm thinking problem totals array somehow, can't figure out. below sample of code:
string printsolution() { int totals[50]; string printablesolution = ""; (int k = 0; k < itemtypecount; k++) { totals[k] = 0; } (int = 0; < itemcount; i++) { totals[items[i].typecode]++; } (int = 0; < itemtypecount; a++) { printablesolution.append("there " + totals[a] + " of item type " + (a + 1) + ". \n"); } }
the problem here:
"there " + totals[a] + " of item type " + (a + 1) + ". \n"
it means char* + int + char* + int + char*
. need print them out separately or alter int
std::string
.
c++ string visual-c++
No comments:
Post a Comment