On Wed, Mar 03, 2004 at 06:48:51PM -0700, Michael Torrie wrote:
> On Wed, 2004-03-03 at 18:43, Justin Findlay wrote:
> > On Wed, Mar 03, 2004 at 04:32:01PM -0700, Von Fugal wrote:
> > > Here's a really simple example with the same problem I'm having. I must be
> > > doing something wrong, and I would guess it's probably in the bag.cpp file.
> > 
> > I remember having problems also trying to do the same thing, but never
> > actually got it resolved.  The hack I used was to define every
> > function of the class template within the header file so that
> > theoretically the compiler is then forced to instantiate the classes
> > you use when it compiles your user program.
> 
> That's not a hack; that's the way it has to be.

"Members of a template class are declared and defined exactly as they would have been 
for a non-template class.  A template member need not be defined within the template 
class itself.  In that case, its definition must be provided somewhere else, as for 
non-template class members."
Bjarne Stroustrup.  The C++ Programming Language Special Edition, p. 330

There are actually source files for the standard template library.

/usr/lib/[path to gcc]/include/g++/bits/*.tcc

where .tcc is the naming convention for template class source files.

Now, how to tell the compiler to correctly instantiate them...


Justin

____________________
BYU Unix Users Group 
http://uug.byu.edu/ 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to