home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!swrinde!sdd.hp.com!spool.mu.edu!think.com!enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!corax.udac.uu.se!buzz.bmc.uu.se!perrier!sundvall
- From: sundvall@perrier.se (Mats Sundvall)
- Newsgroups: comp.lang.c++
- Subject: Re: Template-instantiation fails with referenc
- Message-ID: <1ic177INN3k4@buzz.bmc.uu.se>
- Date: 5 Jan 93 13:07:51 GMT
- References: <stefans.726234949@bauv106>
- Reply-To: sundvall@perrier.se
- Organization: EMBNet Project Sweden
- Lines: 34
- NNTP-Posting-Host: perrier.embnet.se
-
- In article 726234949@bauv106, stefans@bauv.unibw-muenchen.de (Stefan Schwarz) writes:
- >Hi all,
- >
- >just came to a serious problem with templates. Simple code:
- >
- >#include <iostream.h>
- >template <class T> class Collection
- >{
- >private:
- > T *_buffer;
- > T _endtag;
- >public:
- > Collection (size_t size, T endtag) {
- > _buffer = new T [size];
- > _endtag = endtag; }
- >};
-
-
- Collection (size_t size, T endtag) : _endtag(endtag) {
- _buffer = new T [size]; }
- };
-
-
- >This fails with:
- >line 3: error: reference member Collection <Foo&>::_endtag needs initializer
-
- The reference variable _endtag needs an initializr in the constructor. Try the change
- above.
-
- Regrads,
-
- Mats Sundvall
- Uppsala University
- Uppsala, Sweden
-