it is customary to tell us what the problem is.
but I will take a guess: perhaps you forgot to make the parameters reference, so the functions do not seem to change the strings? Also, string x in the function call is not necessary (and I don't know if its correct or not, actually, havent tried it).
In addition to what jonnin mentioned, in your line 13, you're trying to cout a void (twice). Balts and MeIns are both void functions. i.e. They return nothing.
What are you expecting line 13 to display?
Try this:
cout << x << "un " << y;
A couple of other notes:
- i never gets used in your loop. You're going to display the same values of x and y 11 times.
- Do you realize your loop is going to execute 11 times, not 10 due to the <= condition.
Thank you guys, I understood where was the biggest problem, i was trying cout void. And there was 10 times, i don't know why I put <=. So, thank you, guys.
#include <iostream>
usingnamespace std;
string White()
{
return"white";
}
string Black()
{
return"black";
}
int main()
{
string x, y;
for (int i = 0; i < 5; ++i)
{
x += White();
y += Black();
cout << x << " and " << y << '\n';
}
}
white and black
whitewhite and blackblack
whitewhitewhite and blackblackblack
whitewhitewhitewhite and blackblackblackblack
whitewhitewhitewhitewhite and blackblackblackblackblack