RE: [Dev-C++] Is it possible - templates (.h and .cpp) ?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: manish S. <msh...@qu...> - 2004-04-30 15:32:11
|
Well, I guess there is a keyword export(as given in Stroustrup's book) =
whose
purpose is exactly this(separate compilation strategy)..Though as far =
as I
know this is not supported by .NET and CodeWarrior.
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Jorge
Mazzonelli
Sent: Friday, April 30, 2004 7:53 PM
To: dev...@li...
Subject: Re: [Dev-C++] Is it possible - templates (.h and .cpp) ?
Hi,
excuse me but I'm just a newbie in C++ (most of my developpements =
are
made in ANSI-C) but was curious about the subject and made some google
search and found this URL:=20
http://www.cplusplus.com/doc/tutorial/tut5-1.html. There, the author =
says at
the end the following:
/The macro-like functionality of templates, forces a restriction for
multi-file projects: the implementation (definition) of a template =
class or
function _must_ be in the same file as the declaration. That means we =
cannot
separate the interface in a separate header file and we must include =
both
interface and implementation in any file that uses the templates. /
/Going back to the library of functions, if we wanted to make a library =
of
function templates, instead of creating a header file (*.h*) we should
create a "template file" with both the interface and implementation of =
the
function templates (there is no convention on the extension for this =
type of
file other than there be no extension at all or to keep the .h). The
inclusion more than once of the same template file with both =
declarations
and definitions in a project doesn't generate linkage errors, since =
they are
compiled on demand and compilers that allow templates should be =
prepared to
not generate duplicate code in these cases. /
Hope this helped.
Jorge
Ricardo Amores Hern=E1ndez wrote:
> She=B4s not talking about Dev-C++ templates, but *C++ Language*=20
> Templates. ;) More specifically she asked if gcc separate compilation =
> of templates.
> By the way, i=B4m interested in knowing that too :)
>
--
*Jorge H. MAZZONELLI*
e-mail @: jma...@ia... <mailto:jma...@ia...>
|