I have a class graph.h
written like this
#include <fstream>
using namespace std;
template <typename T>
class Graph
{
private:
T ** graphData;
public:
Graph(ifstream & inputFile);
~Graph(){};
friend ofstream & operator<<(ostream&, const Graph &);
};
where constructor Graph(ifstream & inputFile);
is defined in graph.cpp
:
#include "graph.h"
template <typename T>
Graph<T>::Graph(ifstream & inputFile){}
I tried to make an instance of this class in main.cpp:
#include <fstream>
#include "graph.h"
using namespace std;
int main()
{
ifstream myFile ("example.txt");
Graph<int> * IntGraph = new Graph<int>(myFile);
return 0;
}
but I keep getting these errors
Error 1 error LNK2019: unresolved external symbol "public: __thiscall Graph<int>::Graph<int>(class std::basic_ifstream<char,struct std::char_traits<char> > &)" (??0?$Graph@H@@QAE@AAV?$basic_ifstream@DU?$char_traits@D@std@@@std@@@Z) referenced in function _main C:\Users\Vlada\Dropbox\FJFI\BP - Graph partitioning\BP-program\BP-program\main.obj BP-program
Error 2 error LNK1120: 1 unresolved externals C:\Users\Vlada\Dropbox\FJFI\BP - Graph partitioning\BP-program\Debug\BP-program.exe BP-program
I tried to search, but none of the result I found seemed to me like this.