I'm writing a small c++ game, but I'm quite new to c++ because normally I'm writing stuff in java. So I'm not sure where the problem is.
Header-File:
#include <string>
class Game;
class SpeedRatio;
class Monster
{
private:
...
SpeedRatio speed_ratio_; // LINE 36
...
public:
Monster();
//--------------------------------------------------------------------------
// Init Constructor
// @param name the monsters name.
// @param attack_damage the monsters attack damage.
// @param life the monsters life.
// @param attribute the monsters attribute.
// @param speed_ratio the speed ratio.
// @param game the game object.
//
Monster(std::string name, unsigned int attack_damage, unsigned int life,
unsigned int attribute, SpeedRatio speed_ratio, Game &game);
}
CPP-File:
#include "Monster.h"
#include "Game.h"
#include "SpeedRatio.h"
//------------------------------------------------------------------------------
Monster::Monster()
{
}
//------------------------------------------------------------------------------
Monster::Monster(std::string name, unsigned int attack_damage,
unsigned int life, unsigned int attribute,
SpeedRatio speed_ratio, Game &game) : name_(name),
attack_damage_(attack_damage), life_(life),
attribute_(attribute), speed_ratio_(speed_ratio), // LINE 39
game_(&game)
{
}
SpeedRatio.h
class SpeedRatio
{
private:
unsigned int events_;
unsigned int ticks_;
public:
SpeedRatio();
//--------------------------------------------------------------------------
// Init Constructor
// @param events the events.
// @param ticks the ticks.
SpeedRatio(unsigned int events, unsigned int ticks);
}
Now I'm getting 2 error messages:
Description Resource Path Location Type
field 'speed_ratio_' has incomplete type Monster.h /ass1 line 36 C/C++ Problem
Description Resource Path Location Type
class 'Monster' does not have any field named 'speed_ratio_' Monster.cpp /ass1 line 39 C/C++ Problem
T think my (hope) my forward declarations are right.
I marked the lines with comments, thx for any help