delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/17/13:16:07

Newsgroups: comp.os.msdos.djgpp
From: Joshua Hale <jgh AT dcs DOT ed DOT ac DOT uk>
Subject: Templates/Undefined functions
Message-ID: <34E820D1.128E@dcs.ed.ac.uk>
Sender: cnews AT dcs DOT ed DOT ac DOT uk (UseNet News Admin)
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

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> int_list;
 
it complained that it couldn't find function List <Int> : 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019