home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!munnari.oz.au!bunyip.cc.uq.oz.au!uqcspe!cs.uq.oz.au!warwick
- From: warwick@cs.uq.oz.au (Warwick Allison)
- Newsgroups: comp.sys.atari.st
- Subject: Re: problems with gcc/g++
- Message-ID: <9485@uqcspe.cs.uq.oz.au>
- Date: 22 Jul 92 03:59:59 GMT
- References: <bnell.711691021@cadillac>
- Sender: news@cs.uq.oz.au
- Reply-To: warwick@cs.uq.oz.au
- Lines: 53
-
- bnell@siemens.com. (Bill Nell) writes:
-
- >the result file comes out to be like 95 bytes.
-
- >only difference in this file is that it is a class that uses templates.
- >So, can anyone tell me what's wrong???
-
- What's wroing is that Bill, like me, didn't read the C++ Reference Manual
- very carefully.
-
- Templates are not "compiled". That doesn't make any sense. Templates can
- only be compiled once they have been instanciated. Here is the usual usage:
-
-
- main.cc:
-
- #include <SetTempl.cc>
-
- main()
- {
- Set<int> MyIntSet;
- ...
- }
-
-
- SetTempl.cc:
-
- #include <SetTempl.h>
-
- template <class T>
- Set::Set()
- {
- ...
- }
-
-
- SetTempl.h:
-
- template <class T> class Set {
- ...
- };
-
-
-
-
- For more details, RTFM, or check in to comp.lang.c++
- --
- Warwick
- --
- _-_|\ warwick@cs.uq.oz.au /Disclaimer:
- / * <-- Computer Science Department, /
- \_.-._/ University of Queensland, / void (if removed)
- v Brisbane, Australia. /
-