cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/10/04:00:52

From: "Al Combs" <acombs AT uiuc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: More template problems (C++)
Date: Sat, 9 Oct 1999 23:54:04 -0500
Organization: University of Illinois at Urbana-Champaign
Lines: 42
Message-ID: <7tp5ti$sp0$2@vixen.cso.uiuc.edu>
NNTP-Posting-Host: spider.cso.uiuc.edu
X-Newsreader: Microsoft Outlook Express 4.72.3110.5
X-Mimeole: Produced By Microsoft MimeOLE V4.72.3110.3
X-Proxy-Client: acombs AT uiuc DOT edu from PPPa41-ResaleChampaign1-4R1141.saturn.bbn.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Ok, I know I've been here before with template problems, and now I need
specific help again to understand how templates work in DJGPP (G++). Here is
my code:

*** foo.h
template<class Etype>
class Foo
{
public:
  void Replace();
};


***foo.C
#include "foo.h"

template<class Etype>
void Replace()
{}

***main.C
#include "foo.h"

main()
{
  Foo<int> hi;
  hi.Replace();
}


And I get the error on the compilation of the executable:
:main.C: undefined reference to `Foo<int>::Replace(void)'

Now, my question is what SPECIFICALLY would I need to change to make gpp
compile it properly? In otherwords, how would I have to re-write the code to
make it work? Please be as speciffic as possible.

Thanks again,
Al Combs



- Raw text -


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