0
Expected an identifier error
i get an "Expected an identifier" error under the equal sign. please help https://code.sololearn.com/coUhMjD5GAqb/#cpp
17 Antworten
0
In C++ you declare an object with the class/struct name before the object name eg
Player p1; // Player = struct, p1 = object
What you done was Python object declaration
Another thing you should do is
struct player {}; // which is a valid empty struct
Same with the other struct
0
u missunderstood my question
0
What is your question then?
0
so in my code i am checking "if" the following is true, and if it is i want to store the Player struct in the playerClass struct. but when i try to do that it says that there is an expected identifier error on the equal sign
0
Yeah and my 2 suggestions will fix the errors
0
so what should my code be then?
0
https://code.sololearn.com/cLhvkDOlwg0A/?ref=app
That will fix the errors now from what I can see you don’t really understand how structs work so I would highly suggest going over Classes and Objects in the C++ course
0
ummm.. u posted my code
0
Sorry, it didnt save for some reason its fixed now
0
and with this code "player" becomes p1?
0
p1 is type of player
0
yes ok
0
i tried it, and i get "Expected ;" under p1
0
You probably dont have a semi-colon (;) after the p1
0
i do
0
Mind showing the code then?
0
the exact code u sent me