RE: Re[2]: [Dev-C++] templates and inheritance
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <iv...@at...> - 2003-04-30 00:54:15
|
> -----Original Message-----
> From: dev...@li...=20
> [mailto:dev...@li...] On Behalf Of Astar
> Sent: Tuesday, April 29, 2003 11:56 PM
> To: Dev-Cpp mail list
> Subject: Re[2]: [Dev-C++] templates and inheritance
>=20
> :)))) very interesting... of course i have main-function (my project
> consist of ~40-45 files and i thought that writing about my
> main-function (and other parts of project) is unnecessary)
>=20
> i find problem (it isn't absence of main-function :)).
>=20
> I have problem with writing implementation of methods
> (constructor/destructor too) in two files. I mean, if i write it only
> in .h file:
> template <class T, int o>
> class CConteiner{
> CConteiner(){....}
> ~CConteiner(){....};
> };
>=20
> it's OK!(compiling and linking) ....... but if i write implementation
> of constructor/destructor in .cpp file i have link error. I write:
>=20
> template <class T, int o>
> CConteiner<T, optimum>::CConteiner(){
> .......
> }
>=20
> template <class T, int o>
> CConteiner<T, optimum>::~CConteiner(){
> .......
> }
>=20
> what's wrong with my code???
> or may be i must write body of methods in declaration?
>=20
>=20
> PS. sorry for my english :)
The definitions of template functions and classes must be provided at =
every
file you use them. If you wish to place the definition of the template =
in
one implementation file, you have to use the keyword export. Example:
export template<class T>
class whatever
{
// ...
};
However its implementation is very tough, and not many compilers support =
the
keyword "export".
Ioannis Vranos
=20
* Programming pages: http://www.noicys.freeurl.com
* Alternative URL 1: http://run.to/noicys
* Alternative URL 2: http://www.noicys.cjb.net
Anti-racism movement: http://www.positive-youthfoundation.org
Iraq Peace Pledge: http://www.peacepledge.org
|