TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: CAMERON CLARK
date: 1997-05-28 21:57:00
subject: template hell?

    I've been very unsucceful in turning a library into a template class.
    Here's the header:
 dll.h - unsorted double linked list
#define dtype int
#ifndef dll_h
#define dll_h
class Node {
public:
  Node* prev;
  Node* next;
  dtype data;
};
class DLList {
  Node* head;                       // head node in list - dummy node
public:
  Node* cur;                        // current node used to seach the list
  DLList();                         // set up pointers
  ~DLList();                        // deallocate the list
  int findNode(dtype item);         // find item in list
  void insertNodeTail(dtype item);  // insert node at tail
  void insertNodeHead(dtype item);  // insert node at head
  int removeNode(dtype item);       // remove node containing item
  dtype returnCur();                // return the data set by findNode
  void findFirst();
  void findNext();
  void killList();                  // empty the list except for dummy node
};
#endif
    As you can see, dtype should be the template class. After changing the
    header file and the definitions, the source compiles fine but it says
    that the functions DLList::method() is not defined for every
    method.
    template DLList::method() {
    }
    
    This is how I defined each method. 
    template
    class Node {   
         Node* prev;
         Node* next;
         dtype data;
    };
    
    template
    class DLList { 
         Node* head;
         Node* cur;
         method(dtype item);
    }
    This is how I did the headers. Any ideas?
--- GEcho 1.00
---------------
* Origin: Digital OnLine Magazine! - (409)838-8237 (1:3811/350)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.