Why won't this compile?

Why won't this code compile? line 6 gives errors.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  #include <iostream>
#include <fstream>
#include <string>
using namespace std;

string a,b,c,class,save;
int savedata, orc, wizard, mage, goblin, knight;

int main () {
	cout << "Load a save (Y/N)?";
	getline(cin, save);	
	if (save == Y) {
		ret = savedata; }
	else
	cout << "To start let's get some information about you.";
	cout << " Are you an Orc, Wizard, Goblin, Mage, or knight? (Orcs have no starting weapon and are the strongest, Knights have swords and are the 2nd strongest character" << endl;
	cout << "Wizards have a medium magic level and average combat skills. They start with a staff. Goblins are quick but they have a knife and low health with low magic." << endl << "And Mages have a staff and high magic but medium-low health.";
	getline(cin, class);
	if (class == Orc) {
              cout << "Welcome to the world Orc. You have 200 health and no magic.";
              ret == orc; }
    if (class == Wizard) {
              cout << "Welcome to the world Wizard. You have 100 health and 50 magic.";
              ret == wizard; }
	if (class == Mage) {
              cout << "Welcome to the world Mage. You have 50 health and 100 magic.";
              ret == mage; }
	if (class == Goblin) {
              cout << "Welcome to the world Goblin. You have 70 health and 40 magic.";
              ret == goblin; }
	if (class == Knight) {
              cout << "Welcome to the world Knight. You have 150 health and no magic. You also have a sword"; 
              ret == knight; }

int savedata () {

open (class.txt app:end);
if (class.txt == orc) {
   cout << "You are an Orc."; }
}
	
 
What are the errors?
6 G:\Lathui 1.cpp expected unqualified-id before "class"
6 G:\Lathui 1.cpp expected `,' or `;' before "class"
G:\Lathui 1.cpp In function `int main()':
13 G:\Lathui 1.cpp expected primary-expression before "class"
14 G:\Lathui 1.cpp expected primary-expression before "class"
14 G:\Lathui 1.cpp expected `)' before "class"
16 G:\Lathui 1.cpp `ret' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
16 G:\Lathui 1.cpp `orc' undeclared (first use this function)
17 G:\Lathui 1.cpp expected primary-expression before "class"
17 G:\Lathui 1.cpp expected `)' before "class"
19 G:\Lathui 1.cpp `wizard' undeclared (first use this function)
20 G:\Lathui 1.cpp expected primary-expression before "class"
20 G:\Lathui 1.cpp expected `)' before "class"
22 G:\Lathui 1.cpp `mage' undeclared (first use this function)
23 G:\Lathui 1.cpp expected primary-expression before "class"
23 G:\Lathui 1.cpp expected `)' before "class"
25 G:\Lathui 1.cpp `goblin' undeclared (first use this function)
26 G:\Lathui 1.cpp expected primary-expression before "class"
26 G:\Lathui 1.cpp expected `)' before "class"
28 G:\Lathui 1.cpp `knight' undeclared (first use this function)
28 G:\Lathui 1.cpp expected `}' at end of input

I can do the undeclared it is the other stuff.
"class" is not a valid identifier because it is a keyword. Try renaming it to something else.
class is a reserved word, you can't use it as an identifier.
There is only a few errors that is setting everything else off.
Thnx. Trying now.
Took out 8 errors. !2 are left.
Now the errors are




All first use this function.
It doesn't understand ret.
¿what is ret?

By the way, foo; Foo; "foo"; "Foo"; are different
Solved it. Thanks.
Topic archived. No new replies allowed.