delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/09/07/07:45:31

From: Fabrice ILPONSE <fabrice AT asim DOT lip6 DOT fr>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: help - template<class T>
Date: Mon, 07 Sep 1998 13:37:29 +0200
Organization: Universites Paris VI/Paris VII - France
Lines: 39
Message-ID: <35F3C579.4E8D7755@asim.lip6.fr>
References: <35f10110 DOT 1073722 AT news DOT telepac DOT pt> <35F14F9C DOT 8570B044 AT unb DOT ca>
NNTP-Posting-Host: asim.lip6.fr
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Endlisnis wrote:
> 
> Jorge Bruno S. S. Morgado wrote:

>         I think it has to do with the way templates are handled.  math.o is small
> because there is (effectively) nothing in it.  Templates are only compiled
> when a reference to them if found.  No references are found in math.cc.  I
> don't think the linker will link templated functions that had no instances
> during compilation.


	I'm not sure!!
	You have to put all the class in the header.
	The functions are  recreated each time you declare a new template
variable of an inexisting type.

	eg.
		matrix <int> a,b;
		matrix <float> c;

	in fact there'll be 2 differents classes: 1 for int and 1 for float.
	So as the compiler need to know the body of the functions to rebuild
them, they must be in the header file.

Bye!
> --
>      (\/) Endlisnis (\/)
>           s257m AT unb DOT ca
>           Endlisnis AT GeoCities DOT com
>           Endlis AT nbnet DOT nb DOT ca

-- 
	^ ^ ^
	| | |
	+-+-+	Fabrice ILPONSE
	  |	email: fabrice AT asim DOT lip6 DOT fr
	  |
	  |
	  -

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019