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

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!cis.ohio-state.edu!sol.CRd.ge.COM!nguyen
  3. From: nguyen@sol.CRd.ge.COM
  4. Subject: template syntax
  5. Message-ID: <9207282135.AA11012@etamin.crd.Ge.Com>
  6. Sender: gnulists@ai.mit.edu
  7. Reply-To: nguyen@sol.crd.ge.com
  8. Organization: GNUs Not Usenet
  9. Distribution: gnu
  10. Date: Tue, 28 Jul 1992 21:35:49 GMT
  11. Approved: bug-gcc@prep.ai.mit.edu
  12. Lines: 64
  13.  
  14. <..> should be specified in all functions inside a class header,
  15. except constructor and destructor. ARM p.350.
  16.  
  17. The following code compiles with AT&T but not with GNU g++2.0
  18. (gcc-2.2.2). Who is wrong?
  19.  
  20. ----------------------------
  21. #include <iostream.h>
  22.  
  23.  
  24. template<class T1, class T2>
  25. class foo{
  26. public:
  27.   T1 value1;
  28.   T2 value2;
  29.   foo(T1 a, T2 b) { value1 = a; value2 = b;}
  30.   void bar(foo<T1,T2>& t) { value1 = t.value1; value2 = t.value2;} //********
  31.   void print() { cout << value1 << " " << value2 << endl;}
  32. };
  33.  
  34.  
  35.  
  36. main()
  37. {
  38.   foo<int, int> fi(10, 0), fii(0, 5);
  39.   foo<float, int> ff(5.0, 0);
  40.   foo<char, int> fc('c', 1);
  41.  
  42.  
  43.   fi.print();
  44.   fii.print();
  45.   fii.bar(fi);
  46.   fii.print();
  47.   ff.print();
  48.   fc.print();
  49.   
  50.   cout << "hello" << endl;
  51. }
  52. ---------------------------
  53. % /home/thuban/software3/gnu/bin/g++ -I /home/thuban/software3/gnu/lib/g++-incl
  54. ude gnu_template.C
  55. gnu_template.C:10: parse error before `,'
  56. gnu_template.C:10: parse error before `,'
  57. gnu_template.C:10: parse error before `,'
  58. gnu_template.C: In method `void  foo<char ,int>::bar (...)':
  59. gnu_template.C:10: `t' undeclared (first use this function)
  60. gnu_template.C:10: (Each undeclared identifier is reported only once
  61. gnu_template.C:10: for each function it appears in.)
  62. gnu_template.C: In method `void  foo<float ,int>::bar (...)':
  63. gnu_template.C:10: `t' undeclared (first use this function)
  64. gnu_template.C: In method `void  foo<int ,int>::bar (...)':
  65. gnu_template.C:10: `t' undeclared (first use this function)
  66. -------------
  67.  
  68. Van-Duc Nguyen
  69. General Electric 
  70. Research & Development Ctr
  71. 1 River Road, Room K1-5C39.
  72. Schenectady, NY 12301.
  73. Phone: (518) 387-5659
  74. Fax:   (518) 387-6845
  75. nguyen@crd.ge.com
  76.  
  77.  
  78.