home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / gnu / gcc / bug / 2815 < prev    next >
Encoding:
Text File  |  1992-11-21  |  1.4 KB  |  66 lines

  1. Newsgroups: gnu.gcc.bug
  2. Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.berkeley.edu!sethg
  3. From: sethg@cs.berkeley.edu (Seth C. Goldstein)
  4. Subject: gcc 2.3.1 bug with templates in c++
  5. Message-ID: <9211212149.AA20903@boing.CS.Berkeley.EDU>
  6. Sender: gnulists@ai.mit.edu
  7. Organization: GNUs Not Usenet
  8. Distribution: gnu
  9. Date: Sat, 21 Nov 1992 05:49:54 GMT
  10. Approved: bug-gcc@prep.ai.mit.edu
  11. Lines: 53
  12.  
  13. Machine:    sparc
  14. Version:    gcc version 2.3.1
  15. OS:        SunOS Release 4.1.2
  16. problem:    
  17. 1 - The methods in a parameterized class are not implemented by the compiler
  18.     if the definitions are not included in the class definition.  For
  19.     example:
  20.  
  21.     //////////////////////////////// bar.h
  22.     template<class T>
  23.     class Bar
  24.     {
  25.         T data;
  26.     public:
  27.         inline Bar(T i);
  28.         T get(void);
  29.     };
  30.     
  31.     
  32.     template<class T> inline 
  33.     Bar<T>::Bar(T i)
  34.     {
  35.         data = i;
  36.     }
  37.     //////////////////////////////// EOF
  38.     //////////////////////////////// bar.C
  39.     #include "bar.h"
  40.     
  41.     template<class T> T
  42.     Bar<T>::get(void)
  43.     {
  44.         return data;
  45.     }
  46.     //////////////////////////////// EOF
  47.     //////////////////////////////// user.C
  48.     #include <stdio.h>
  49.     #include "bar.h"
  50.     
  51.     main()
  52.     {
  53.         Bar<int> bi(2);
  54.     
  55.         printf("%d\n", bi.get());
  56.     }
  57.     //////////////////////////////// EOF
  58.  
  59.     when compiled with: gcc-2.3.1 -o test bar.C user.C generates the
  60.     following linktime error:
  61.  
  62.     ld: Undefined symbol 
  63.        _get__t3Bar1Zi 
  64.  
  65.  
  66.