Topic: HELP: template won't link!


Author: kbbenten@cs.vu.nl (K.B. van Benten)
Date: Thu, 29 Sep 1994 14:16:56 GMT
Raw View
Hi there,

I've got this problem a list-template.
Using these files:

// list.h
#ifndef LIST_H
#define LIST_H
template <class T> class Node
{
    friend class List<T>;
    private:
        Node(T);
        ~Node();
        T       Data;
        Node<T> *Next;
        Node<T> *Prev;
};

template <class T> class List
{
    public:
        List();              // Constructor
        ~List();             // Destructor
    private:
        Node<T> *Head;
        Node<T> *Current;
        Node<T> *Tail;
};

#endif

// list.cpp

#include "list.h"
template <class T> Node<T>::Node(T Object)
{
    Next = 0;
    Prev = 0;
    Data = Object; // '=' is overloaded
}

template <class T> Node<T>::~Node()
{
}

template <class T> List<T>::List()
{
    Head = 0;
    Current = 0;
    Tail = 0;
}

template <class T> List<T>::~List()
{
}

// TestList

#include "list.h"

int main()
{
    List<int> IntList;
    return 1;
}

Linux g++ (UNIX compiler gives me a similar error) gives me this:

/tmp/cca010112.o: Undefined symbol List<int>::List(void)
                        referenced from text segment
/tmp/cca010112.o: Undefined symbol List<int>::~List(void)
                        referenced from text segment
/tmp/cca010112.o: Undefined symbol List<int>::~List(void)
                        referenced from text segment


What can I do 'bout this?

Thanx

Kasper van Benten