home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16705 < prev    next >
Encoding:
Text File  |  1992-11-21  |  769 b   |  27 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!spool.mu.edu!darwin.sura.net!jvnc.net!princeton!csservices!elan!mg
  3. From: mg@elan (Michael Golan)
  4. Subject: template member func:  class X { template<class T> f(T& x) {...}}
  5. Message-ID: <mg.722310420@elan>
  6. Sender: news@csservices.Princeton.EDU (USENET News System)
  7. Organization: Princeton University, Dept. of Computer Science
  8. Date: 21 Nov 92 01:47:00 GMT
  9. Lines: 16
  10.  
  11. Why isnt this allowed?
  12.  
  13. class File {
  14.     binwrite(void *buf,size_t sz) {...} // write buf of length sz 
  15. public:
  16.     template<class T> write(T& buf) { binwrite(buf,sizeof(T)); }
  17. };
  18.  
  19. of course I can do
  20.  
  21. template<class T> write(File& f,T& buf) { f.binwrite(buf,sizeof(T)); }
  22.  
  23. But it isn't quite the same thing - write becomes global!
  24.  
  25.  Michael Golan
  26.  mg@princeton.edu
  27.