Re: [Dev-C++] Is it possible - templates (.h and .cpp) ?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Carla M. W. <ca...@lr...> - 2004-04-30 18:10:11
|
Hi, Thank you very much. This was exactly what I wanted to know. It is a pitty that it is not possible to divide the implementation in .h and .cpp files. Thanks, Carla. On Fri, 30 Apr 2004, Jorge Mazzonelli wrote: > Hi, > excuse me but I'm just a newbie in C++ (most of my developpements=20 > are made in ANSI-C) but was curious about the subject and made some=20 > google search and found this URL:=20 > http://www.cplusplus.com/doc/tutorial/tut5-1.html. There, the author=20 > says at the end the following: >=20 > /The macro-like functionality of templates, forces a restriction for=20 > multi-file projects: the implementation (definition) of a template class= =20 > or function _must_ be in the same file as the declaration. That means we= =20 > cannot separate the interface in a separate header file and we must=20 > include both interface and implementation in any file that uses the=20 > templates. / >=20 > /Going back to the library of functions, if we wanted to make a library= =20 > of function templates, instead of creating a header file (*.h*) we=20 > should create a "template file" with both the interface and=20 > implementation of the function templates (there is no convention on the= =20 > extension for this type of file other than there be no extension at all= =20 > or to keep the .h). The inclusion more than once of the same template=20 > file with both declarations and definitions in a project doesn't=20 > generate linkage errors, since they are compiled on demand and compilers= =20 > that allow templates should be prepared to not generate duplicate code=20 > in these cases. / >=20 >=20 >=20 >=20 > Hope this helped. >=20 > Jorge >=20 >=20 > Ricardo Amores Hern=E1ndez wrote: >=20 > > 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 :) > > >=20 > --=20 > *Jorge H. MAZZONELLI* > e-mail @: jma...@ia... <mailto:jma...@ia...> >=20 |