Correct usage of Template Class

Hello there, first time poster so be gentle ;)
So I'm currently making a program and am trying to use Template classes and I'm unsure if what I'm doing is correct due to a LNK2019 error being generated.
What I'm doing is using class x with class y being defined as its template....have a look at my code I'm unsure how to word it

1
2
3
4
5
6
7
8
9
10
11
12
13
14
  int main()
{
	char* filepath = "Test_Map.txt";
	double* tempMap = readTXT(filepath, 8, 11);
	Map<Node<double>> * grid = new Map<Node<double>>(8,11);
	for (int i = 0; i<8*11; i++)
	{
		double t = tempMap[i];
		Node<double> * tempNode = new Node<double>(t);
		grid->set_node(i,tempNode);
	}
	Sleep(1000);
	return 0;
}


So as you can see, Map is a template class and so is Node can you use templates as templates ??

Thanks to anyone that helps out

edit:

Adding the error messages that have been generates

1
2
3
4
5
error LNK2019: unresolved external symbol "public: __thiscall Map<class Node<double> >::Map<class Node<double> >(int,int)" (??0?$Map@V?$Node@N@@@@QAE@HH@Z) referenced in function _main

error LNK2019: unresolved external symbol "public: __thiscall Node<double>::Node<double>(double)" (??0?$Node@N@@QAE@N@Z) referenced in function _main	

error LNK2019: unresolved external symbol "public: void __thiscall Map<class Node<double> >::set_node(int,class Node<double> *)" (?set_node@?$Map@V?$Node@N@@@@QAEXHPAV?$Node@N@@@Z)
Last edited on
You did not show what linker error message was generated. Maybe it was generated as the result that a class template declaration and its member definitions are in different modules.
Added the error messages to my original post
It looks like that you placed the definition of the template class and definitions of its members in different modules.
Topic archived. No new replies allowed.