Hi, I have another question. This one is about header files. I have a header for a player and the opponent of my battleship game. They way I have it set up, the opponent needs a player object to make a move, and vise versa. This is what i have.
Opponent Header:
/*
* File: opponent.h
* Author: Neil
*
* Created on June 16, 2009, 4:25 PM
*/
#ifndef _OPPONENT_H
#define _OPPONENT_H
#include "ship.h"
#include "field.h"
#include "player.h"
#include <vector>
#include <iostream>
class opponent {
public:
opponent();
opponent(const opponent& orig);
virtual ~opponent();
void placeShips();
void makeMove(player p);
bool takeHit(int x, int y);
void storeShips(std::vector<Ship> ships){this->ships=ships;}
std::vector<Ship> getShips(){return ships;}
private:
std::vector<Ship> ships;
Field shipArea;
Field guessArea;
};
#endif /* _OPPONENT_H */
Player Header:
/*
* File: player.h
* Author: Neil
*
* Created on June 16, 2009, 5:10 PM
*/
#ifndef _PLAYER_H
#define _PLAYER_H
#include "opponent.h"
#include "ship.h"
#include "field.h"
#include <vector>
#include <iostream>
class player {
public:
player();
player(const player& orig);
virtual ~player();
void placeShips();
void makeMove(opponent o);
bool takeHit(int x, int y);
void printFields();
void storeShips(std::vector<Ship> ships){this->ships=ships;}
std::vector<Ship> getShips(){return ships;}
void updateShipField();
void updateGuessField(int x, int y);
private:
std::vector<Ship> ships;
Field shipArea;
Field guessArea;
};
#endif /* _PLAYER_H */
And this is the error I'm getting:
In file included from opponent.h:13,
from opponent.cpp:9:
player.h:24: error: `opponent' has not been declared
player.h:24: error: ISO C++ forbids declaration of `o' with no type