cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/14/19:31:26

From: Stefan Neis <neis AT cdc DOT informatik DOT th-darmstadt DOT de>
Newsgroups: comp.lang.c++,comp.os.msdos.djgpp,gnu.g++.help
Subject: Re: templates
Followup-To: gnu.g++.help
Date: 13 May 1997 18:25:59 GMT
Organization: Technische Hochschule Darmstadt
Lines: 46
Message-ID: <5labnn$1lh$1@news.th-darmstadt.de>
References: <01bc5fc6$6d16b7e0$0b88099a AT dennis DOT worldonline DOT nl>
NNTP-Posting-Host: cdc24.cdc.informatik.th-darmstadt.de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In gnu.g++.help Dennis Janssen <nessnaj AT worldonline DOT nl> wrote:
: Hi,

: I'm new to C++ and now I'm trying to learn how to use templates.

: I've written the following three files.

: [CSTACK.H]

: [CSTACK.CC]

: [TESTSTCK.CC]
: #include "cstack.h"

: int main ()
: {
:   cStack<int> int_stack;

:   int_stack.push(12);

:   return 0;
: }

: How do I fix this? I've read something in info about GCC neither supporting
: the Borland model nor the C/C++ frontend (or something) but I don't
: understand how to fix it. 

Just read again what the info file says. Though it's quite obscure at
first, the meaning gets clearer everytime you read it.

Assuming you want to use the last method suggested, do the following:
Create a file 'instant.cc' containing

#include "cstack.h"
#include "cstack.cc"

template class cStack<TYPE>;

and compile this file with 
'gcc -fno-implicit-templates -DTYPE=int -o cstack_int.o'
(and do same for every type you need besides int).
Then compile your program and link it together with these instantiations...

	Stefan Neis

P.S.: Followup-To changed.

- Raw text -


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