Mail Archives: djgpp/2001/10/19/06:18:48.1
From: | Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Compiling problem
|
Date: | 19 Oct 2001 10:13:06 GMT
|
Organization: | Aachen University of Technology (RWTH)
|
Lines: | 29
|
Message-ID: | <9qoubi$asj$1@nets3.rz.RWTH-Aachen.DE>
|
References: | <007301c15846$1208b4c0$0101a8c0 AT hernan>
|
NNTP-Posting-Host: | acp3bf.physik.rwth-aachen.de
|
X-Trace: | nets3.rz.RWTH-Aachen.DE 1003486386 11155 137.226.32.75 (19 Oct 2001 10:13:06 GMT)
|
X-Complaints-To: | abuse AT rwth-aachen DOT de
|
NNTP-Posting-Date: | 19 Oct 2001 10:13:06 GMT
|
Originator: | broeker@
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
R. Grela <rgrela AT ciudad DOT com DOT ar> wrote:
> I'm trying to compile a template class, I don't know what I am doing wrong:
> I 've this: (it's the simplest test)
[...]
> --- test.cpp ---
> #include "test.h"
> template <class T>
> test<T>::test()
> {
> }
> --- end of test.cpp ---
Here's your problem. It's a basic misunderstanding of how templates
work, in all but the very latest dialects of C++ (--> the new
"exports" keyword).
One of the main differences between an ordinary class and a template
is that a template cannot usually have a separate implementation file
(like this test.cpp of yours) --- the whole implementation *must* be
#included into the code using the template, i.e. it should be in the
header file. Templates cannot be compiled separately.
A quick fix would be to remove the #include test.h from your test.cpp,
and instead #include "test.cpp" at the end of test.h. Or just copy the
contents into there, right away.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -