home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!wupost!usc!sol.ctr.columbia.edu!usenet.ucs.indiana.edu!nsundare@silver.ucs.indiana.edu
- From: nsundare@silver.ucs.indiana.edu (Neelakantan Sundaresan)
- Newsgroups: comp.lang.c++
- Subject: Problem with templates...
- Message-ID: <Bu0xvC.6np@usenet.ucs.indiana.edu>
- Date: 3 Sep 92 22:45:07 GMT
- Sender: <nsundare@silver.ucs.indiana.edu>
- Organization: Indiana University
- Lines: 52
- X-Mailer: ELM [version 2.3 PL11]
-
-
- I am trying to separate compile template definitions and use.
- For instance,
- file1.c has
- -----
-
- #include <stdio.h>
- #include <stdarg.h>
- #include "file1.h"
-
- template <class T> XT<T>::Xtest(T t)
- { printf("HEE\n");
- return 0;
- }
- template <class T> XT<T>::XT(){}
-
- file2.c has
- ------
-
- #include <stdio.h>
- #include <stdarg.h>
- #include "file1.h"
-
- main()
- {
- typedef XT<int> Y;
- Y x;
- x.Xtest(4);
- }
-
- file1.h has
- -------
-
- template <class T> class XT {
- public:
- XT();
- Xtest(T);
- };
-
-
- ------------ On compiling with g++ and linking I get the error
- undefined symbol:
- ___t2XT1Zi
- _Xtest__t2XT1Zii
-
- But if I have file1.c and file2.c in the same file, everything seems
- to be okay.
-
-
- Any ideas as to what is going on?
- thanks
- Neel.
-