This is strange. How can it possibly be that I get an error when I'm including an .h file (GeneralSearch.h) but everything seems to work just fine when, instead, I include the .cpp file (GeneralSearch.cpp)?
.h file
#ifndef GENERALSEARCH_H_
#define GENERALSEARCH_H_
#include "Problem.h"
#include "Node.h"
template <class T>
class GeneralSearch
{
public:
const Node* treeSearch(const Problem &problem) const;
const Node* graphSearch(const Problem &problem, T &fringe = T()) const;
private:
void expand(const Node &node, const Problem &problem, list<const Node*> &out) const;
};
#endif
.cpp file
#include "GeneralSearch.h"
template <class T>
void GeneralSearch<T>::expand(const Node &node, const Problem &problem, list<const Node*> &out) const
{
...
}
template <typename T>
const Node* GeneralSearch<T>::treeSearch(const Problem &problem) const
{
...
}
template <typename T>
const Node* GeneralSearch<T>::graphSearch(const Problem &problem, T &fringe = T()) const
{
...
}
the program file - WORKING
#include "GeneralSearch.cpp"
#include "DummyProblem.h"
#include "DepthFirstSearch.h"
#include <queue>
int main (int argc, char* argv[]){}
the program file - NOT WORKING
#include "GeneralSearch.h"
#include "DummyProblem.h"
#include "DepthFirstSearch.h"
#include <queue>
int main (int argc, char* argv[]){}