I have a very simple template class.
#pragma once
#include <iostream>
template <class T>
class Test
{
protected:
class Node
{
public:
Node(Node& node) {}
protected:
virtual Node* copyNode(Node&);
private:
};
};
template <class T>
Test<T>::Node* Test<T>::copyNode(Test<T>::Node& node)
{
return new Test<T>::Node(node);
}
I use it in the main program as follows.
#include "Test.h"
using namespace std;
int main()
{
Test<int> tree;
getchar();
}
I get a syntax error C2061: "identifier 'Node'".
Both the declaration and the implementation are in the same header file (the linker has problems with template classes). I am using Visual Studio 2015.
What is the proper way of implementing the copyNode
method without writing it inline?