From: Jason Green Newsgroups: comp.os.msdos.djgpp Subject: Re: template header files Date: Sun, 10 Sep 2000 11:45:22 +0100 Organization: Customer of Energis Squared Lines: 29 Message-ID: References: <39BAE868 DOT B8948FF7 AT operamail DOT com> NNTP-Posting-Host: modem-151.georgia.dialup.pol.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: newsg4.svr.pol.co.uk 968582778 11416 62.137.61.151 (10 Sep 2000 10:46:18 GMT) NNTP-Posting-Date: 10 Sep 2000 10:46:18 GMT X-Complaints-To: abuse AT theplanet DOT net X-Newsreader: Forte Agent 1.7/32.534 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Sahab Yazdani wrote: > hello i have written my own linked list template file and now want to > use it as a library (you know in different executables, etc). the > problem is that for every time that I write: > > LinkedList bob; > > the linker returns "undefined reference to LinkedList" and refuses > to actually compile the code. i have included as attachment the header > file for the linked list, the actual code and a short sample program > using this library (which obviously doesn't work..) The simplest way to use templates is to put the implementation of the class template in the header file, not in a separate source file. In your case that means cut and paste everything from linkedlist.cc into linkedlist.h, and delete linkedlink.cc. Or, if you prefer, #include "linkedlist.cc" from linkedlist.h. You do not compile linkedlist.cc so there is no linkedlist.o to link with. > thank you in advance for any help you may provide. > > PS. Sorry if this isn't a DJGPP specific question... I believe this is a C++ FAQ.