Reputation: 124
I've got a bizarre error with templating. It's very simple code, but it's throwing two errors. What's wrong with it?
The error:
node.h|3|error: expected unqualified-id before ‘<’ token
node.cpp|3|error: expected unqualified-id before ‘<’ token
Header file:
#pragma once
<template typename T>
class Node
{
public:
Node(T data);
T data;
Node * next;
};
#include "node.cpp"
Implementation file:
#include "node.h"
<template typename T>
Node<T>::Node(T nd) : data(nd), next(NULL)
{
}
Upvotes: 1
Views: 1998
Reputation: 38218
Templates are template <typename T>
. The <
goes after the template
keyword.
Upvotes: 4