🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.help
Article #781

Re: Nested Templates

#781
From: Albert Golembiowski
Date: Fri, 06 Oct 1995 14:21
55 lines
2044 bytes
Hi Brian,

the `-fno-implicit-templates' is the thing to do.
The only thing I can think of you might've missed is to
include also the template class implementation file as well.
Too bad that g++-2.7.0 doesn't signal this condition (another flag, please?).

template class Vector<int>;

ag> From: bbury@archangel.nswc.navy.mil (Brian Bury) writes:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ag> // Martix2D.h
ag> #ifndef MATRIX2D_H
ag> #define MATRIX2D_H
ag> 
ag> #include "Vector.h"
ag> 
ag> // Matrix2D.h -- Definition of a 2d Matirx class
ag> 
ag> template <class T>
ag> class Matrix2D : public Vector< Vector<T> >
ag> {
ag>   protected:
ag> 	int 	yDim;
ag>   public:
ag> 	Matrix2D( int=0, int=0 );
ag> 	int rows() { return len; }
ag> 	int cols() { return yDim; }
ag> };
ag> #endif
ag> 
<snip>
ag> 
ag> #include "Vector.h"
ag> #include "Matrix2D.h"
ag> 
ag> template class Vector<int>;
ag> template class Vector< Vector<int> >;
ag> template class Matrix2D<int>;
ag> int main(void)
ag> {
ag>         Matrix2D<int>   testMat(5, 2);
ag> 
ag>         for( int j = 0; j < 2; j++ )
ag>                 for ( int i = 0; i < 5; i++ )
ag>                         testMat[i][j] = i*j;
ag> 
ag>         return 0;
ag> }

-- 
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Albert Golembiowski      albert@inrs-telecom.uquebec.ca         (514) 762-8655
INRS Telecommunications, 16 Place du Commerce, Verdun, Quebec, Canada, H3E 1H6
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Technical Details
Message-ID: <9510050252.AA14550@nora>
Path: arc1-ca.pugleaf.net!inrs-telecom.uquebec.ca!albert
References: <1995Oct2.125810.10558@relay.nswc.navy.mil>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!inrs-telecom.uquebec.ca!albert
From: albert@inrs-telecom.uquebec.ca (Albert Golembiowski)
Newsgroups: gnu.g++.help,comp.lang.c++
Subject: Re: Nested Templates
Date: 6 Oct 1995 10:21:37 -0400
Organization: Gatewayed from the GNU Project mailing list help-g++@prep.ai.mit.edu
Sender: daemon@cis.ohio-state.edu
Distribution: world
Message-ID: <9510050252.AA14550@nora>
References: <1995Oct2.125810.10558@relay.nswc.navy.mil>