🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #336

Re: template syntax

#336
From: Joe Buck
Date: Wed, 29 Jul 1992 02:17
29 lines
1233 bytes
In article <9207282135.AA11012@etamin.crd.Ge.Com> nguyen@sol.crd.ge.com writes:
>The following code compiles with AT&T but not with GNU g++2.0
>(gcc-2.2.2). Who is wrong?

gcc/g++ is wrong, but it's not surprising given the ambiguity of some of
the template specs. If you change the problem line in your template class
definition from

>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;}
>};

to

	...
  void bar(foo& t) { value1 = t.value1; value2 = t.value2;}
	...

your program compiles, runs, and produces the right answers.


--
Joe Buck	jbuck@ohm.berkeley.edu
Technical Details
Message-ID: <154v3fINNi1m@agate.berkeley.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!forney.berkeley.edu!jbuck
References: <9207282135.AA11012@etamin.crd.Ge.Com>

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!forney.berkeley.edu!jbuck
From: jbuck@forney.berkeley.edu (Joe Buck)
Subject: Re: template syntax
Message-ID: <154v3fINNi1m@agate.berkeley.edu>
Sender: gnulists@ai.mit.edu
Organization: U. C. Berkeley
References: <9207282135.AA11012@etamin.crd.Ge.Com>
Distribution: gnu
Date: Wed, 29 Jul 1992 02:17:19 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 30