// cPlayer.h#include <iostream>#include <string>using namespace std;class cPlayer;{public: cPlayer (string, int);// -cPlayer(){} int getHealth(); int getMoney(); void setHealth(int); void setMoney(int);private: int signed itsHealth; int itsMoney; string itsName;}
// cPlayer.cpp#include "cPlayer.h"cPlayer::cPlayer(string name, int money){ itsHealth=100; itsMoney=money; itsName=name;}int cPlayer::getHealth(){ return itsHealth;}int cPlayer::getMoney(){ return itsMoney;}void cPlayer::setHealth(int health){ itsHealth=health;}void cPlayer::setMoney(int money){ itsMoney+=money;}
Still gettin errors:
cPlayer.h:9: error: expected unqualified-id before '{' token
cPlayer.h:9: error: expected `,' or `;' before '{' token
cPlayer.cpp:6: error: invalid use of undefined type `struct cPlayer'
cPlayer.h:8: error: forward declaration of `struct cPlayer'
cPlayer.cpp: In constructor `cPlayer::cPlayer(std::string, int)':
cPlayer.cpp:7: error: `itsHealth' undeclared (first use this function)
cPlayer.cpp:7: error: (Each undeclared identifier is reported only once for each function it appears in.)
cPlayer.cpp:8: error: `itsMoney' undeclared (first use this function)
cPlayer.cpp:9: error: `itsName' undeclared (first use this function)
cPlayer.cpp: At global scope:
cPlayer.cpp:13: error: invalid use of undefined type `struct cPlayer'
cPlayer.h:8: error: forward declaration of `struct cPlayer'
cPlayer.cpp: In member function `int cPlayer::getHealth()':
cPlayer.cpp:14: error: `itsHealth' undeclared (first use this function)
cPlayer.cpp: At global scope:
cPlayer.cpp:17: error: invalid use of undefined type `struct cPlayer'
cPlayer.h:8: error: forward declaration of `struct cPlayer'
cPlayer.cpp: In member function `int cPlayer::getMoney()':
cPlayer.cpp:18: error: `itsMoney' undeclared (first use this function)
cPlayer.cpp: At global scope:
cPlayer.cpp:21: error: invalid use of undefined type `struct cPlayer'
cPlayer.h:8: error: forward declaration of `struct cPlayer'
cPlayer.cpp: In member function `void cPlayer::setHealth(int)':
cPlayer.cpp:22: error: `itsHealth' undeclared (first use this function)
cPlayer.cpp: At global scope:
cPlayer.cpp:25: error: invalid use of undefined type `struct cPlayer'
cPlayer.h:8: error: forward declaration of `struct cPlayer'
cPlayer.cpp: In member function `void cPlayer::setMoney(int)':
cPlayer.cpp:26: error: `itsMoney' undeclared (first use this function)