Newsgroups: comp.os.msdos.djgpp From: Joshua Hale Subject: Templates/Undefined functions Content-Type: text/plain; charset=us-ascii Message-ID: <34E820D1.128E@dcs.ed.ac.uk> Sender: cnews AT dcs DOT ed DOT ac DOT uk (UseNet News Admin) Content-Transfer-Encoding: 7bit Organization: Department of Computer Science, Edinburgh University Mime-Version: 1.0 Date: Mon, 16 Feb 1998 11:19:46 GMT Lines: 27 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I am having some problems using template classes. I defined a list class with a template for the typ of elements. I found that if I tried to just include the list header file (with just the class definitions of the list class) in my main code file it compiled all the .o files properly, but when it came to link them gcc complained that it couldn't find the list functions. ie if I defined: class List int_list; it complained that it couldn't find function List : length() and any other functions. I solved this problem by including the whole list code in the main code file so that it didn't need to link the files. However, when I tried to define about 3 different types of list with different templates it started complaining about undefined functions in the same way again. Has anyone had a similar problem where template classes generate undefined functions when they are instantiated with specific types, and can anyone suggest a fix? Thanks, Josh Hale