I know there are different ways to write code for the "Rock, Paper, Scissors" game. But I have tried to write the following code based on my elementary knowledge of C++.
using std::cin;
using std::cout;
using std::endl;
int main(int argc, char** argv) {
enum object {rock, paper, scissors}
object player1, player2;
cout <<"Enter two objetcs (objects include rock, paper or scissors):";
cin >>player1 >> player2;
if (player1==player2) cout <<"objects are equal";
else if (player1==rock && player2=paper cout << "player 2 is the winner";
else if (player1==rock && player2=scissors cout<<"player 1 is the winner";
else if (player1==paper && player2=rock) cout << "player 1 is the winner";
else if (player1==paper && player2=scissors) cout <<"Palyer 2 is the winnder";
else if (player1==scissors && player2=paper) cout << "Player 1 is winner";
else cout <<"Player 2 is the winner";
}
The compiler (Dev-C++)
finds error with cin >>player1 >> player2;
line, explaining that "In Function 'int main(int, char**): [error] expected initializer before 'player1'"
. I do not get the meaning of this warning. How I can I improve this code without too much change in its structure?