Mail Archives: djgpp/1998/02/17/13:16:07
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 -