delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/09/01:14:13

From: makulik AT tf16 DOT mch DOT sni DOT de (Makulik.Guenther T 27528 R 91-811 WS tx24 )
Newsgroups: comp.os.msdos.djgpp
Subject: Re: template classes with DJGPP
Date: 5 Aug 1997 12:28:15 GMT
Organization: Siemens Nixdorf Inc.
Lines: 31
Message-ID: <5s768v$n84$1@horus.mch.sni.de>
References: <01bca10d$bb446600$0100a8c0 AT stefan DOT schimanski>
NNTP-Posting-Host: tmntn.mch.sni.de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Stefan Schimanski (stefan DOT schimanski AT metronet DOT de) wrote:
: Hi,

: I've implemented the following template class, that simulates a dynamic
: array. Although I've put the whole definition of the class in the header
: file, the linker displays errors. The compiler works fine. The linker can't
: find the constructor definition:

: Error: contest.o: In function `global constructors keyed to C':
: contest.cc(24) Error: undefined reference to
: `CContainer<int>::CContainer(int)'
: There were some errors

: I've removed the parameter of the constructor an tried again. But I got the
: same error. I know that some parameter for gcc exist to control the way it
: handles template. Would some of them help?

May be, I didn't try for myself. The problem could be either that you omitted
the #pragma interface directive, or that you have to declare you implementations
as inline explicitely.
Try to write the implementation code inside the class definition.

BTW why are you defining a container class (if not for study purposes), use STL
components. These will be much more reliable than your own implementations and
provide a lot of standard container types. 
I've not got it on my hand now, but if you're interested I can mail you where
to find good documentation on STL on request. The headers and implementations are 
already part of the DJGPP standard C++ environment.

HTH
Guenther

- Raw text -


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