home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / gnu / gcc / bug / 2022 < prev    next >
Encoding:
Text File  |  1992-07-29  |  1.2 KB  |  44 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!forney.berkeley.edu!jbuck
  3. From: jbuck@forney.berkeley.edu (Joe Buck)
  4. Subject: Re: template syntax
  5. Message-ID: <154v3fINNi1m@agate.berkeley.edu>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: U. C. Berkeley
  8. References: <9207282135.AA11012@etamin.crd.Ge.Com>
  9. Distribution: gnu
  10. Date: Wed, 29 Jul 1992 02:17:19 GMT
  11. Approved: bug-gcc@prep.ai.mit.edu
  12. Lines: 30
  13.  
  14. In article <9207282135.AA11012@etamin.crd.Ge.Com> nguyen@sol.crd.ge.com writes:
  15. >The following code compiles with AT&T but not with GNU g++2.0
  16. >(gcc-2.2.2). Who is wrong?
  17.  
  18. gcc/g++ is wrong, but it's not surprising given the ambiguity of some of
  19. the template specs. If you change the problem line in your template class
  20. definition from
  21.  
  22. >template<class T1, class T2>
  23. >class foo{
  24. >public:
  25. >  T1 value1;
  26. >  T2 value2;
  27. >  foo(T1 a, T2 b) { value1 = a; value2 = b;}
  28. >  void bar(foo<T1,T2>& t) { value1 = t.value1; value2 = t.value2;} //********
  29. >  void print() { cout << value1 << " " << value2 << endl;}
  30. >};
  31.  
  32. to
  33.  
  34.     ...
  35.   void bar(foo& t) { value1 = t.value1; value2 = t.value2;}
  36.     ...
  37.  
  38. your program compiles, runs, and produces the right answers.
  39.  
  40.  
  41. --
  42. Joe Buck    jbuck@ohm.berkeley.edu
  43.  
  44.