Я пишу небольшую игру C++, но я довольно новичок в C++, потому что обычно я пишу материал в java. Поэтому я не уверен, где проблема.Неполный тип поля C++
Заголовок-файл:
#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-файл:
#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);
}
Теперь я получаю сообщения об ошибках 2:
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 думаю, что мои (надежды) мои передовые декларации верны. Я указал строки с комментариями, thx для любой помощи
возможно дубликат [ "поле имеет неполный тип"] (http://stackoverflow.com/questions/12466055/field-has-incomplete-type) – crashmstr
Поиск по вашему названию имеет много релевантных результатов [неполное поле типа C++] (http://stackoverflow.com/search?q=incomplete+field+type+%5Bc%2B%2B%5D) – crashmstr