So I 3 classes as follows:
class Weapon {
char* name;
Target target;
int hitStrength;
public:
Methods...
};
class Player {
char* name;
int level;
int life;
int strength;
Weapon weapon;
int location;
public:
Methods...
};
class Game {
int maxPlayers;
Player** players;
public:
Methods...
};
I am having trouble with includes.
I have a main.cpp
file which has the following includes:
#include "Game.h"
#include <iostream>
using namespace std;
However, when I try to build the program I get the following error:
In file included from C:\Users\Name\CLionProjects\Call Of Matam Duties\Player.h:8:0,
from C:\Users\Name\CLionProjects\Call Of Matam Duties\Game.h:8,
from C:\Users\Name\CLionProjects\Call Of Matam Duties\main.cpp:1:
C:\Users\Name\CLionProjects\Call Of Matam Duties\Weapon.h:30:12: error: 'ostream' does not name a type
friend ostream& operator<< (ostream& os, const Weapon& w);`
To mention:
Player.cpp
includes Player.h
;
Weapon.cpp
includes Weapon.h
;
Game.cpp
includes Game.h
;
Game.h
includes Player.h
and Weapon.h
.
Is it correct?
How can I fix this?
If you need more information, let me know.