H.Das
H.Das

Reputation: 225

Not Understanding Template Error in My Code [ C++ ]

I got an error in my Code :

"Nested name specifier 'Node<T>::' for declaration does not refer into a class, class template or class template partial specialization."

I'm not understand why this error happen.Guys how can i solve this error in my C++ code and the member function must implement outside of the class.

template<typename T, typename  =typename std::enable_if<isMyType<T>::value>::type>
class Node{
  T t;
public:
  T getT();
};

template<typename T, typename  =typename std::enable_if<isMyType<T>::value>::type>
T Node<T>::getT(){
return t;
}

Upvotes: 0

Views: 73

Answers (1)

rafix07
rafix07

Reputation: 20918

The error is clear, there is no Node as class template taking one type parameter. You declared Node as class template taking two types.

Default type parameters should be only in declaration of template. In definition you don't provide it again.

Outside definition should be:

template<typename T,typename U>
T Node<T,U>::getT(){
    return t;
}

Demo

Upvotes: 2

Related Questions