Problem with classes.
Jul 15, 2013 at 4:48am Jul 15, 2013 at 4:48am UTC
hello, i'm following a ebook i bought from game institute it says the following
http://puu.sh/3Dchg.png
this is what i've wrote onto my script
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
int main ()
{
// properties -> functions.
class Wizard
{
public :
//Functions
void fight();
void talk();
void castSpell();
//Variables
std::string mName;
int mHitPoints;
int mMagicPoints;
int mArmor;
};
void Wizard::fight()
{
cout << "Fighting." << endl;
}
}
but i get these errors
http://puu.sh/3DckQ.png
to be honest i'm only new to this so i dont know what the error means fully what i can grasp though is that, the member function ( method ) is being changed since i implimented it inside wizard but i dont see how that happens, i might be completely wrong sorry.
any help or anything will be greatly appreciated :)
Jul 15, 2013 at 4:50am Jul 15, 2013 at 4:50am UTC
I'm sorry i forgot which forum i clicked on to post this i thought it was beginners. what do i do ?
Jul 15, 2013 at 4:53am Jul 15, 2013 at 4:53am UTC
Define the class, methods and functions outside `main()'
Jul 15, 2013 at 9:39am Jul 15, 2013 at 9:39am UTC
And inside main, something like:
1 2 3 4 5 6 7 8 9
int main()
{
Wizard Gandalf;
Gandalf.fight();
return 0;
}
Topic archived. No new replies allowed.