home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.gcc.bug
- Path: 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
-
- 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
-
-