home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.gcc.bug
- Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cs.berkeley.edu!sethg
- From: sethg@cs.berkeley.edu (Seth C. Goldstein)
- Subject: gcc 2.3.1 bug with templates in c++
- Message-ID: <9211212149.AA20903@boing.CS.Berkeley.EDU>
- Sender: gnulists@ai.mit.edu
- Organization: GNUs Not Usenet
- Distribution: gnu
- Date: Sat, 21 Nov 1992 05:49:54 GMT
- Approved: bug-gcc@prep.ai.mit.edu
- Lines: 53
-
- Machine: sparc
- Version: gcc version 2.3.1
- OS: SunOS Release 4.1.2
- problem:
- 1 - The methods in a parameterized class are not implemented by the compiler
- if the definitions are not included in the class definition. For
- example:
-
- //////////////////////////////// bar.h
- template<class T>
- class Bar
- {
- T data;
- public:
- inline Bar(T i);
- T get(void);
- };
-
-
- template<class T> inline
- Bar<T>::Bar(T i)
- {
- data = i;
- }
- //////////////////////////////// EOF
- //////////////////////////////// bar.C
- #include "bar.h"
-
- template<class T> T
- Bar<T>::get(void)
- {
- return data;
- }
- //////////////////////////////// EOF
- //////////////////////////////// user.C
- #include <stdio.h>
- #include "bar.h"
-
- main()
- {
- Bar<int> bi(2);
-
- printf("%d\n", bi.get());
- }
- //////////////////////////////// EOF
-
- when compiled with: gcc-2.3.1 -o test bar.C user.C generates the
- following linktime error:
-
- ld: Undefined symbol
- _get__t3Bar1Zi
-
-
-