This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Template bug ?


Munagala V S Ramanath writes:

> When I add <> after the function names at lines 14 and 15 as suggested
> by the diagnostic I get further errors:

> ------------------------------------------------------------------------
> ram@dust tests: /d2a/exper/bin/gcc bug2.C -lstdc++
> bug2.C:13: parse error before `>'

there must be a declaration of the function template before it is
referred to inside the body of the class template.  In order to
declare the function template before the definition of the class
template, you must have already declared the class template, like
this:

template< class T, class UT, int NFRAC >
class Fixed;

template< class T, class UT, int NFRAC > inline Fixed< T, UT, NFRAC >
Mul( const Fixed< T, UT, NFRAC > &a1,
     const Fixed< T, UT, NFRAC > &a2 );

template< class T, class UT, int NFRAC > ostream &
operator<<( ostream &os, const Fixed< T, UT, NFRAC > &a );

template< class T, class UT, int NFRAC >
class Fixed {
// ...

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]