Re: [Dev-C++] Is it possible - templates (.h and .cpp) ?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jorge M. <jma...@ia...> - 2004-04-30 14:23:14
|
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:
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ández wrote:
> She´s not talking about Dev-C++ templates, but *C++ Language*
> Templates. ;)
> More specifically she asked if gcc separate compilation of templates.
> By the way, i´m interested in knowing that too :)
>
--
*Jorge H. MAZZONELLI*
e-mail @: jma...@ia... <mailto:jma...@ia...>
|