class Monster
{
public:
Monster(int hp, int acc, int xpReward, int armor, constchar* weaponName, int lowDamage, int highDamage);
bool isDead();
COORD pos;
int getXPReward();
int getArmor();
void attack(CPlayer& player);
void takeDamage(int damage);
void displayHitPoints();
private:
int mHitPoints;
int mAccuracy;
int mExpReward;
int mArmor;
Weapon mWeapon;
};
When you declare new instance of Monster class, you need to pass in essential parameters as declared in constructor of class
something like this:
Monster* m_Monsters = new Monster(hp, acc, xpReward, armor .... );
To be able to declare an array of Monster pointers, you probably want to do this:
in Monster class, add an empty constructor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
class Monster
{
public:
//Constructor
Monster(int hp,
int acc,
int xpReward,
int armor,
constchar* weaponName,
int lowDamage,
int highDamage);
//default constructor
Monster();
....
Then in your main(), or wherever you wanna create the array.
do this:
1 2 3 4 5 6 7 8 9
//Example
constchar thang[10] = "THANG DO";
int i = 1;
//This is to create new instances of Monster
Monster* pMonster = new Monster(1, 1, 1 ,1 , &thang[0], 1, 1);
//This will create an array of Monster type
Monster* array = new Monster[i];
class CGame
{
private:
ConLib* m_Console;
int m_LastAction;
int m_GameStatus;
COORD m_Arena;
CPlayer m_Player;
Monster* m_Monsters;
int m_MonstersNumber;
And in one func i want to make an array of Monsters:
m_Monsters = new Monster[m_MonstersNumber];
But i can't??????
I want to use this array of Monsters to get his position, hitpoints,......