I have an error called Unexpected Token 'class', did you forget a ;? I have no clue what is going on. Maybe you guys can help me out. The codes name is Player.h. The error is on line 9.

#ifndef PLAYER_H
#define PLAYER_H

#include "Weapon.h"
#include "Armor.h"
#include "Monster.h"
#include <string>

class Player
{
public: 
    Player();
    void createClass(); 
    int getArmor(); 
    bool isDead(); 

    void goToArena(); 
    void store();
    void rest(); 
    void viewStats(); 
    void loseMoney(int cost); 
    void buyWeapon(const std::string& name, int lowDamage, int highDamage); 
    void buyArmor(const std::string& name, int protection);
    bool attack(Monster& monster); 
    void takeDamage(int damage); 
    void victory(int xp, int gold); 
    void levelUp(); 
    void gameover(); 
    void displayHitPoints(); 

private: 
    std::string mName; 
    std::string mClassName; 
    int         mExperiancePoints; 
    int         mNextLevelExp;
    int         mHealthPoints; 
    int         mMaxHealthPoints; 
    int         mLevel; 
    int         mAccuracy; 
    int         mGold; 
    Weapon      mWeapon; 
    Armor       mArmor; 
}; 

#endif

Recommended Answers

All 2 Replies

In this case, the error is most likely in one of the header files you are including, with the most probably cause being that you omitted a semi-colon at the end of a class definition.

Thanks for the quick response. That was exactly what it was.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.