I made a class and split it into a source and header file, but I can’t get them to talk to each other.
My header file, GridLayout.h that looks something like this:
#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 looks like:
#include "GridLayout.h"
namespace Spaceships {
GridLayout::GridLayout() {
}
//GridLayout::aBunchOfOtherFunctions() { }
}
#endif
When I compile, I get a whole slew of GridLayout does not name a type errors. What could be causing this? I seem to remember solving a similar problem once by throwing in a bunch of semicolons, but that doesn’t seem to be working this time.
Figured it out! I’ll put this here in case it helps somebody.
I must have set GridLayout.h to be compiled at some point, then changed it back, because there was a GridLayout.gch lying around in the directory. So the compiler must have gone straight for that and ignored the .h altogether. I deleted that file and now it shows me all the real errors in my code.