I keep getting "Unknown type name 'Life
'" in world.h
and "Unknown type name 'Life
'" and "Unknown type name 'World
'" in game.h
.
I have a feeling that there might be too many include statements based on other posts but I can't find the solution in this case.
Any help/hints will be greatly appreciated
game.h
#pragma once
#ifndef LIFE_H
#include "life.h"
#define LIFE_H
#endif
#ifndef WORLD_H
#include "world.h"
#define WORLD_H
#endif
class Game {
public:
// Constructor/destructor
Game(Life **life, int numLife);
~Game();
void game_loop();
private:
World * m_world;
int m_steps;
bool m_automate;
};
world.h
#pragma once
#ifndef LIFE_H
#include "life.h"
#define LIFE_H
#endif
#ifndef WORLD_H
#include "world.h"
#define WORLD_H
#endif
class World {
public:
// Constructor/destructor
World();
~World();
void print() const;
bool initLife(Life *life);
void updateWorld();
private:
char getNextState(char state, char row, char col, bool toggle) const;
char **m_grid_1;
char **m_grid_2;
bool m_toggle;
};
life.h (without any errors)
#ifndef life_h
#define life_h
#ifndef life_h
#include "life.h"
#define life_h
#endif
#ifndef GAME_H
#include "game.h"
#define GAME_H
#endif
class Life {
public:
int getCol() const; // const member functions cannot modify member variables.
int getRow() const;
int getHeight() const;
int getWidth() const;
char getFromFigure(int r, int c) const;
protected:
int m_col;
int m_row;
int m_height;
int m_width;
char **m_sprite;
World *m_world;
};
#endif