Trebuchette
Trebuchette

Reputation: 124

Strange template error: expected unqualified-id

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

Answers (1)

Cornstalks
Cornstalks

Reputation: 38218

Templates are template <typename T>. The < goes after the template keyword.

Upvotes: 4

Related Questions