I have class Queue
that is implemented with templates, one parameter for the type and one constant parameter for the size of the queue.
template <typename T, int N>
class Queue
{
.....
void enqueue(T x);
}
I want to specialize the enqueue
method, for the typename but I can not figure how to do this.
template <typename T, int N>
void Queue<Heap<struct infoNod>, N>::enqueue(Heap<struct infoNode> x)
{}
For specializing the entire class I am not sure if i do it right: in header:
template <>
class Queue<Heap<struct infoNode>, 100>
{
public:
void enqueue(Heap<struct infNode> x);
};
in cpp:
template <>
void Queue<Heap<struct infoNod>, 100>::enqueue(Heap<struct infoNode> x) {}
errors:
Queue.cpp:77:6: error: template-id ‘enqueue<>’ for ‘void Queue<Heap<infoNod>, 100>::enqueue(Heap<infoNode>)’ does not match any template declaration
void Queue<Heap<struct infoNod>, 100>::enqueue(Heap<struct infoNode> x)
^
Queue.cpp:77:78: note: saw 1 ‘template<>’, need 2 for specializing a member function template
void Queue<Heap<struct infoNod>, 100>::enqueue(Heap<struct infoNode> x)