-
dumb error need help
I dont know why this error exists. Heres my code. Theres more about 4 files but this is the one with the error.
Code:
#ifndef GUARD_Stage1
#define GUARD_Stage1
#include <iostream>
class Stage1
{
private:
int wcount, ncount, scount, ecount;
int west, north, south, east; //directions
public:
Stage1() : west(0),north (0),south(0),east (0), wcount(0), ncount(0), scount (0), ecount (0) // long constructor
{}
void int_wcount(); //count how many
void int_ecount(); // times the
void int_scount(); // user
void int_ncount(); // went either direction
void getarea(); // get users choice of destination
void fight(); // if in a fight
void win(); // if you win
void lose(); // if you lose
};
void Stage1::int_wcount() //error!!!!!!!!!!!!!!!!!!!!!
{ wcount++ }
void Stage1::int_ecount()//error
{ ecount++ }
void Stage1::int_scount()//error
{ scount++ }
void Stage1::int_ncount()//error
{ ncount++ }
void Stage1::getarea()
{
int areach = 0;
cout << " Choose your destination(1,2,3,4)"<<endl;
cout << " 1: West "<<endl;
cout << " 2: East "<<endl;
cout << " 3: South "<<endl;
cout << " 4: North "<<endl;
cin.ignore( 10, '\n' );
if( !cin.good( ) ) {
cout << "Error?!" << endl;// here
cout << areach << endl;// here
}
switch (areach)
{
case 1:
void Stage1::int_wcount();
break;
case 2:
void Stage1::int_ecount();
break;
case 3:
void Stage1::int_scount();
break;
case 4:
void Stage1::int_ncount();
break;
default:
cout <<"error sorry";
break;
}
}
void Stage1::fight()
{
int youdam; //users damage
int totdam; //total damage
int fch; // for switch
cout << "You have entered a battle";
cout << "1)punch";
cout << "2)kick";
cout << "3)defend";
switch (fch)
{
case 1:
cout << "you have punched 10 damage";
totdam - 10;
youdam - 5;
break;
case 2:
cout <<"you have kicked 5 damage";
totdam - 5;
youdam - 10;
break;
case 3:
cout <<"you defend, lose 5 damage";
youdam - 5;
break;
default:
cout <<"error";
break;
}
}
#endif
Here are my compiler errors
------------------------------------------------------------------------------------
5 C:\Dev-Cpp\Main.cpp
In file included from Main.cpp
C:\Dev-Cpp\Stage1.h
In method `void Stage1::int_wcount()':
24 C:\Dev-Cpp\Stage1.h
parse error before `}'
C:\Dev-Cpp\Stage1.h
In method `void Stage1::int_ecount()':
26 C:\Dev-Cpp\Stage1.h
parse error before `}'
C:\Dev-Cpp\Stage1.h
In method `void Stage1::int_scount()':
28 C:\Dev-Cpp\Stage1.h
parse error before `}'
C:\Dev-Cpp\Stage1.h
In method `void Stage1::int_ncount()':
30 C:\Dev-Cpp\Stage1.h
parse error before `}'
C:\Dev-Cpp\Makefile.win
[Build Error] [Main.o] Error 1
------------------------------------------------------------------------------------
If you guys need the whole code ill post it. Let me know
thx for your help.
-
Aren't you forgetting a semicolon ';' in in wcount++,ecount++,
scount++ and ncount++ ??
-
but i dont put any on any of my other functions. i thought they dont go there. and i tried putting semicolons all over. it doesnt work. someone help!!!
-
you forgot the semicolons in your member function definitions IE:
void Stage1::int_wcount()
{ wcount++; } // Add the semicolon to all of the ones like this
also, in the fight sequence you're not initializing any of the variables you use, and for the places where it appears you're trying to subtract life, you should use -= not -
IE:
totdam - 10; // This doesn't really do anything with the resulting value
totdam -=10;// subtracts 10 from totdam and stores t back to totdam
-
Thx man. Your always there to help. and thx for the other help to. i cant believe i made another stupid mistake.