home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16752 < prev    next >
Encoding:
Text File  |  1992-11-22  |  1.2 KB  |  32 lines

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