home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!spool.mu.edu!darwin.sura.net!jvnc.net!princeton!csservices!elan!mg
- From: mg@elan (Michael Golan)
- Subject: template member func: class X { template<class T> f(T& x) {...}}
- Message-ID: <mg.722310420@elan>
- Sender: news@csservices.Princeton.EDU (USENET News System)
- Organization: Princeton University, Dept. of Computer Science
- Date: 21 Nov 92 01:47:00 GMT
- Lines: 16
-
- Why isnt this allowed?
-
- class File {
- binwrite(void *buf,size_t sz) {...} // write buf of length sz
- public:
- template<class T> write(T& buf) { binwrite(buf,sizeof(T)); }
- };
-
- of course I can do
-
- template<class T> write(File& f,T& buf) { f.binwrite(buf,sizeof(T)); }
-
- But it isn't quite the same thing - write becomes global!
-
- Michael Golan
- mg@princeton.edu
-