home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!mole-end!mat
- From: mat@mole-end.matawan.nj.us
- Subject: Re: Template functions as class members
- Message-ID: <1992Nov22.191502.1156@mole-end.matawan.nj.us>
- Summary: No templates as member functions, sorry.
- Organization: :
- References: <1ej5hqINN1lb@cardamom.compnews.co.uk>
- Date: Sun, 22 Nov 1992 19:15:02 GMT
- Lines: 20
-
- In article <1ej5hqINN1lb@cardamom.compnews.co.uk>, rogera@compnews.co.uk (Roger Allen) writes:
- > ... is it possible to have template functions as class member functions?
- > I've tried it ... but it complains at the syntax ... I sat and pondered
- > this and can't think why this shouldn't be possible.
-
- Sorry, no, you can't. But remember that every member function of a template
- class IS a template.
-
- Oh, why not? Well, for one thing a user can provide an explicit version
- for any templated function. Since the member function has access to the
- class's private parts, this would allow anyone to write a function that
- would violate encapsulation without any changes to or actions with the
- class header.
-
- Think about it.
- --
- (This man's opinions are his own.)
- From mole-end Mark Terribile
-
- mat@mole-end.matawan.nj.us, Somewhere in Matawan, NJ
-