🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #831

Re: template syntax

#831
From: Mike Stump
Date: Sat, 29 Aug 1992 14:53
63 lines
2331 bytes
This problem should not exist in the next release of gcc.

g++ was wrong, hum, I mean is wrong. AT&T is correct.  My g++ compiles
it just fine.  :-)

> Date: Tue, 28 Jul 92 17:35:49 EDT
> From: nguyen@sol.crd.ge.com
> Message-Id: <9207282135.AA11012@etamin.crd.Ge.Com>
> Reply-To: nguyen@sol.crd.ge.com

> <..> should be specified in all functions inside a class header,
> except constructor and destructor. ARM p.350.

> The following code compiles with AT&T but not with GNU g++2.0
> (gcc-2.2.2). Who is wrong?

> ----------------------------
> #include <iostream.h>


> template<class T1, class T2>
> class foo{
> public:
>   T1 value1;
>   T2 value2;
>   foo(T1 a, T2 b) { value1 = a; value2 = b;}
>   void bar(foo<T1,T2>& t) { value1 = t.value1; value2 = t.value2;} //********
>   void print() { cout << value1 << " " << value2 << endl;}
> };



> main()
> {
>   foo<int, int> fi(10, 0), fii(0, 5);
>   foo<float, int> ff(5.0, 0);
>   foo<char, int> fc('c', 1);


>   fi.print();
>   fii.print();
>   fii.bar(fi);
>   fii.print();
>   ff.print();
>   fc.print();
>   
>   cout << "hello" << endl;
> }
> ---------------------------
> % /home/thuban/software3/gnu/bin/g++ -I /home/thuban/software3/gnu/lib/g++-incl
> ude gnu_template.C
> gnu_template.C:10: parse error before `,'
> gnu_template.C:10: parse error before `,'
> gnu_template.C:10: parse error before `,'
> gnu_template.C: In method `void  foo<char ,int>::bar (...)':
> gnu_template.C:10: `t' undeclared (first use this function)
> gnu_template.C:10: (Each undeclared identifier is reported only once
> gnu_template.C:10: for each function it appears in.)
> gnu_template.C: In method `void  foo<float ,int>::bar (...)':
> gnu_template.C:10: `t' undeclared (first use this function)
> gnu_template.C: In method `void  foo<int ,int>::bar (...)':
> gnu_template.C:10: `t' undeclared (first use this function)
> -------------
Technical Details
Message-ID: <9208291453.AA29428@cygnus.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!mrs

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!mrs
From: mrs@cygnus.com (Mike Stump)
Subject: Re:  template syntax
Message-ID: <9208291453.AA29428@cygnus.com>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Sat, 29 Aug 1992 14:53:11 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 64