Solved
Template issue - what's wrong with this line...?
Posted on 2000-02-14
I am trying to compile some sample code and am getting the error:
"..error C2059: syntax error : '<' "
on the line:
friend class CList<NodeType>;
The entire h file Code:
///////////////////////////////////////////////////////////////////////////////
//
// File Name
// TEMPLATE.H
//
// Description
//
// Author
// Les Thaler
//
// Revision: 1.00
//
// Copyright (c) 1995 Microsoft Corporation. All rights reserved.
//
#ifndef _TEMPLATE_H_
#define _TEMPLATE_H_
#include <windows.h>
#include <stdio.h>
#include <mapidefs.h>
template <class NodeType> class CNode;
template <class NodeType>
class CNode
{
friend class CList<NodeType>; // Original line as found in the sample
public:
CNode(const NodeType & Type);
~CNode(){};
private:
CNode * m_pNext; //
NodeType m_Item; // variable length, put last
};
template <class NodeType>
class CList
{
public:
CList();
~CList();
BOOL WINAPI Insert(const NodeType & val);
BOOL WINAPI InsertAsc(const NodeType & val);
BOOL WINAPI Delete(const NodeType &,NodeType ** ret);
NodeType * WINAPI Find(const NodeType &SearchTarget);
// same as Walk but doesn't copy the node
NodeType * WINAPI Scan(BOOL bWalking = 1);
// same as Scan but returns a copy of the node
NodeType * WINAPI Walk(BOOL bWalking = 1);
ULONG WINAPI Size();
NodeType * WINAPI Dequeue();
VOID WINAPI Destroy();
BOOL WINAPI Queue(const NodeType & val);
CList<NodeType> & operator -=(CList<NodeType> & Deletions);
CList<NodeType> & operator +(CList<NodeType> & Suffix);
private:
CNode<NodeType> * m_pHead,
* m_pTemp,
* m_pTail; // used by Walk
ULONG m_ulCnt;
};
#endif
// End of file for TEMPLATE.H