[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] C++ template problem



On Sat, Apr 06, 2002 at 04:35:11PM +0200, Mads Bondo Dydensborg wrote:
> On Sat, 6 Apr 2002, Anders Hellerup Madsen wrote:
> 
> > Jeg kan godt gætte at problemet er, at gcc ikke ved hvilke udgaver af
> > templateklassen der vil være brug for når den kompilerer klasse.cpp, og
> > derfor ikke laver en udgave der virker med integers. Men hvordan får man
> > det til at virke?
> 
> Lægger koden i .h filen. Det sutter, men sådan er det med templates. Der 
> er nogen oversættere der måske kan noget andet, men de snyder! Og, det er 
> ikke portabelt, svjv.
Eksplicit instantiering burde kunne løse problemet, hvis du virkelig vil
have implementationen af din template ud af headeren... Og det burde
være portabelt (Jeg har set det virke i MSVC).

Det gør du i den fil hvor du implementerer template funktionerne skriver
du:

template class klasse<int>;

Så ved compileren at den skal oversætte en udgave af klasse som virker
på int's...

-- 
/-----------------------------------------------------\
| Klaus S. Madsen      | "Failure is not an option... |
| ICQ: 45400164        |  It comes bundled with your  |
| www.hjernemadsen.org |  Microsoft products!"        |
\-----------------------------------------------------/


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:09 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *