クラスを作成し、それをソース ファイルとヘッダー ファイルに分割しましたが、相互に通信できません。
私のヘッダーファイルはGridLayout.h
次のようになります。
#ifndef GRIDLAYOUT_H_INCLUDED
#define GRIDLAYOUT_H_INCLUDED
#include <vector>
#include <types.h>
#include "GridPlaceable.h"
namespace Spaceships {
class GridLayout {
//consider replace with std::list
typedef std::vector<GridPlaceable*> column;
public:
GridLayout();
~GridLayout();
void arrange();
void splitColumn(size_t colNo, distance position);
void splitRow(size_t rowNo, distance position);
bool placeOne(GridPlaceable* thatOne);
private:
bool tryToFit(GridPlaceable* thatOne, size_t startCol, size_t startCell);
std::vector<column> wholeGrid;
std::vector<GridPlaceable*> toPlace;
std::vector<distance> rowHeights, colWidths;
std::vector<size_t> firstEmpties;
bool mandates;
};
};
GridLayout.cpp
次のようになります。
#include "GridLayout.h"
namespace Spaceships {
GridLayout::GridLayout() {
}
//GridLayout::aBunchOfOtherFunctions() { }
}
#endif
コンパイルすると、大量のGridLayout does not name a type
エラーが発生します。何が原因でしょうか? セミコロンをたくさん入れて同様の問題を解決したことを覚えているようですが、今回はうまくいかないようです。