Im having a little bit of trouble with my new program. I cant seem to figure it out.
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
class Enemy
{
private:
int Ehealth;
int Elevel;
string Ename;
public:
Enemy(const string& n, int eh, int el):
Ename(n), Ehealth(eh), Elevel(el){}
const string & get_name(){return Ename;}
int get_level(){return Elevel;}
int get_health(){return Ehealth;}
};
class Stats
{
private:
int health;
int xp;
int money;
string name;
public:
Stats(const string& n, int x, int h, int m):
name(n), health(h), xp(x), money(m){}
const string & get_pname(){return name;}
int get_health(){return health;}
int get_xp(){return xp;}
int get_money(){return money;}
};
class Trex: public Enemy
{
private:
int stomp;
int bite;
public:
Trex(const string& n, int eh, int el, int a1, int a2):
Enemy(n, eh, el), stomp(a1), bite(a2){}
};
class Player: public Stats
{
public:
Player(string& n, int x, int h, int m):
Stats(n, x, h, m){}
};
int main()
{
Enemy* Etrex = new Trex("T-Rex", 100, 1, 25, 34);
Stats* Pstats = new Player("Player1", 0, 100, 0);
cout << Trex << endl;
delete Etrex;
delete Pstats;
}
|
I got these errors but i cant figure out what i need to fix.
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp||In constructor 'Enemy::Enemy(const std::string&, int, int)':|
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp|12|warning: 'Enemy::Ename' will be initialized after|
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp|10|warning: 'int Enemy::Ehealth'|
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp|14|warning: when initialized here|
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp||In constructor 'Stats::Stats(const std::string&, int, int, int)':|
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp|28|warning: 'Stats::name' will be initialized after|
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp|25|warning: 'int Stats::health'|
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp|30|warning: when initialized here|
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp||In function 'int main()':|
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp|59|error: no matching function for call to 'Player::Player(const char [8], int, int, int)'|
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp|52|note: candidates are: Player::Player(std::string&, int, int, int)|
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp|50|note: Player::Player(const Player&)|
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp|61|error: expected primary-expression before '<<' token|
C:\Users\Chay Hawk\Desktop\Battle Arena\main.cpp|59|warning: unused variable 'Pstats'|
||=== Build finished: 2 errors, 7 warnings ===|