Thread: Linked List
View Single Post
Old Jan 22nd, 2006, 9:56 AM   #3
Animatronic
Programmer
 
Join Date: Jun 2005
Posts: 99
Rep Power: 4 Animatronic is on a distinguished road
Where are definitions for:

virtual ~CLinkedList(void);
virtual void add(const Tipo &);
virtual bool remove(const Tipo &);
virtual void showAll();

for most compilers template definitions need tobe available to every source file, so the function definitions should be present in the header file, either inside the class declaration or after.

Also are you sure you want to make them virtual, I cant see a reason to inherit off of the class.


No<Tipo> *top;
No<Tipo> *tail;

Shouldn't that be either head/tail or top/bottom .

The second template <class Tipo> in your class declaration is redundant.

const Tipo *p;

Are you sure you want to make that const, it would mean that you could only ever get const access to your data inside your linklist. Also why make it a pointer that will mean an extra call to malloc/new on insert, when you could just have the object itself.

edit:
You need to place the code in the headers for most compilers because the compiler neesd to generate the complete code for the class, in that source file, when it meets a instantiation of a template.
Animatronic is offline   Reply With Quote