I am trying to create a sort of text RPG, but I haven't programmed in a few weeks, and am not sure why I get the errors. I define the class and all the variables within the class, then try to create an instance of it, but the compiler vehemently protests my doing so.
Update:
I added
char words;
before
int input
I also added a semicolon after input and changed
cin >> input;
to
cin >> words;
Now I have six error messages. Well, that's one less than seven.
#include <iostream>
usingnamespace std;
int main()
{
char words;
int input;
class thing
{
public:
int STR;
int DEX;
int CON;
int INT;
int WIS;
int CHA;
int HP;
int AC;
int name;
private:
}
thing player;
cout << "Enter your name:\n";
cin >>words;
words = player.name;
cout << player.name;
cin.get();
}
1 2 3 4 5 6 7 8 9 10 11 12 13
1
1>Compiling...
1>main.cpp
1>c:\users\noahpocalypse\documents\visual studio 2008\projects\proto_rpg\proto_rpg\main.cpp(26) : error C2146: syntax error : missing ';' before identifier 'player'
1>c:\users\noahpocalypse\documents\visual studio 2008\projects\proto_rpg\proto_rpg\main.cpp(26) : error C2065: 'player' : undeclared identifier
1>c:\users\noahpocalypse\documents\visual studio 2008\projects\proto_rpg\proto_rpg\main.cpp(30) : error C2065: 'player' : undeclared identifier
1>c:\users\noahpocalypse\documents\visual studio 2008\projects\proto_rpg\proto_rpg\main.cpp(30) : error C2228: left of '.name' must have class/struct/union
1> type is ''unknown-type''
1>c:\users\noahpocalypse\documents\visual studio 2008\projects\proto_rpg\proto_rpg\main.cpp(31) : error C2065: 'player' : undeclared identifier
1>c:\users\noahpocalypse\documents\visual studio 2008\projects\proto_rpg\proto_rpg\main.cpp(31) : error C2228: left of '.name' must have class/struct/union
1> type is ''unknown-type''
1>Build log was saved at "file://c:\Users\noahpocalypse\Documents\Visual Studio 2008\Projects\proto_rpg\proto_rpg\Debug\BuildLog.htm"
1>proto_rpg - 6 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========