Thread: template list syntax error

  1. #1
    GA ichijoji's Avatar
    Join Date
    Nov 2002

    template list syntax error

    Ok, I'm working on a game and I'm having problems with constructors when allocating arrays of object, so I decided I'd make a generic linked list structure to get around it. So far I've got the specification written:
    #ifndef MYLIST2_H
    #define MYLIST2_H
    template <class T>
    class mylist;
    template <class T>
    class node {
        node* next;
        T data;
        friend class mylist<T>;
    template <class T>
    class mylist {
        node *head, *cursor;
        void addtoend(T);
        void addtostart(T);
        void remove();
        void addbefore();
        void clear();
    This looks good to me, but when I compile it I get a 'syntax error before '*'' on this line:
    node *head, *cursor*;
    What am I doing wrong?
    Illusion and reality become impartiality and confidence.

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    node is a template class, you need to specify its type:
    node<T> *head, *cursor;
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 10:43 AM
  5. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM