Hey i have no idea whats goin wrong with this i think its to do with the fact that its in private but i have an error with calling weapon in the monster class (Monster.cpp) the error states that it is inaccessable :S here is my code:
//Monster.h
#ifndef MONSTER_H
#define MONSTER_H
#include "Weapon.h"
#include <string>
class Player;
class Monster
{
public:
Monster(std::string name, int health, int hitPoints,
int miss, int damage,const std::string& weaponName);
bool Death();
int getXPReward();
std::string getName();
int getArmour();
void attack(Player& player);
void takeDamage(int damage);
void displayHitPoints();
void print();
void save(std::ofstream& outFile);
void load(std::ifstream& inFile);
private:
std::string name;
int health;
int hitPoints;
int miss;
int Damage;
Weapon weapon;
};
#endif //MONSTER_H
#include "Weapon.h"
#include <iostream>
using namespace std;
Monster::Monster(std::string name, int health, int hitPoints,
int miss, int damage,const std::string& weaponName)
{
name = name;
hitPoints = hitPoints;
Weapon weapon;
miss = miss;
damage = damage;
weapon.name= weaponName; // <------ error is here.
}
bool Monster::Death()
{
return hitPoints <= 0;
}
//Weapon.h
#ifndef WEAPON_H
#define WEAPON_H
#include "Range.h"
#include <string>
struct Weapon
{
std::string Name;
Range DamageRange;
};
#endif //WEAPON_H