Class name does not name a type

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#pragma once

#include "Board.h"
#include "Ship.h"
#include <string>
#include <vector>
#include <iostream>

using namespace std;

class Player{
public:
	Player(string playerName, string boardFileName);
	void showBoard() const;
	//Bomb getBomb() const;
	//void attackBoard(const Bomb &b);
private:
	string name;
	Board board;
};


Board.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once

#include "Player.h"
#include "Ship.h"
#include <string>
#include <vector>
#include <iostream>
using namespace std;

class Ship;


class Board {
public:
	Board(const string &filename);
	void putShip(const Ship &s);
	void moveShips();
	//bool attack(const Bomb &b);
	void display()const;
	void show()const;
	int getLines();
	int getColumns();
	bool checkLimits(int line, int col, const Ship &s);

private:
	int numLines, numColumns;
	vector<Ship> ships;
	vector <vector <int> > board;

};


Hey there, why, when compiling I get the error that "Board does not name a type"? I have "Board.h" included. Why would this happen?

Regards
Last edited on
http://www.cplusplus.com/forum/articles/10627/
see point 6 for a blind guess of what is happening in your case (¡you, information withholder!)
see point 4 to fix it
Last edited on
Without seeing the contents of Board.h I can only assume that the class declaration/definition is in error?
Board.h added.

I did some changes on Player.h adding

 
class Board;


and

 
Board *board


But now on my Player.cpp, on my constructor:

1
2
3
4
5
Player::Player(string playerName, string boardFileName)
: name(playerName), board(boardFileName)
{
	board=Board(boardFileName);
}


cannot convert ‘Board’ to ‘Board*’ in assignment
Topic archived. No new replies allowed.