Template Class Won't Compile Once Method is Called

I am new to C++ and trying to implement a basic template class. I am using Visual Studio 2013 for reference. I can create the class, members and methods without issue. I can also init an instance with issue but as soon as I got to call a method off the class I get the following:

MyCppTestApp.obj : error LNK2019: unresolved external symbol "public: void __thiscall Test::Stack<int>::test(void)" (?test@?$Stack@H@Test@@QAEXXZ) referenced in function _wmain

MyCppTestApp.exe : fatal error LNK1120: 1 unresolved externals

Stack.h:
1
2
3
4
5
6
7
8
9
namespace Test
{
	template <class T>
	class Stack {
	
	public:
		void test();
	};
}


Stack.cpp:

1
2
3
4
5
6
7
8
9
10
#include "stdafx.h"
#include "Stack.h"

namespace Test
{
	template <class T>
	void Stack<T>::test() {
		
	}
}


Entry Point:

1
2
3
4
5
int _tmain(int argc, _TCHAR* argv[])
{
  Test::Stack<int> intStack;  // No isses here
  intStack.test(); //Issue occurs when I call test
}
Template implementations need to be accessible to the compiler at the point of compilation. What happens if you move the implementation into the header?

https://isocpp.org/wiki/faq/templates#templates-defn-vs-decl
So that fixed the issue. I deleted the .cpp file and simply implemented within the .h file. Everything now compiles and works without issue.

Thank you so much for your help, I have been tearing my hair out for the last hour on this.
Topic archived. No new replies allowed.