Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!samsung!umich!umeecs!msi-s0.msi.umn.edu!cs.umn.edu!ux.acs!hopper From: hopper@ux.acs.umn.edu (hopper) Newsgroups: comp.std.c++ Subject: Re: the most dissatisfying part of c++ Message-ID: <1923@ux.acs.umn.edu> Date: 31 Jul 90 22:49:36 GMT References: <27634@netnews.upenn.edu> <10599@batcomputer.tn.cornell.edu> Reply-To: hopper@ux.acs.umn.edu (Eric Hopper) Organization: Omnifarious Software Lines: 57 In article <10599@batcomputer.tn.cornell.edu> lijewski@tcgould.tn.cornell.edu (Mike Lijewski) writes: >In article <27634@netnews.upenn.edu> limsoon@saul.cis.upenn.edu.UUCP (Limsoon Wong) writes: > >>the program below is a contrived one. it cannot be compiled. >>the reason is a type fault. however, it exhibits a very central >>characteristic of update. something should be done to allow >>this kinds of programs. ---limsoon. > >I disagree completely that such programs should be allowed. Since test() >returns a `a&', basically what you are asking is that there be a implicit >conversion from a base class to a derived class. No way should this be >allowed. If you really want the below program to work, one possibility >would be to add the following constructor definitions to the class >declaration of b: > > b() {}; > b(a) {}; I propose that there should be a generic class declaration for a method that returns the same type as the class which it is part of. Example: class A { me &func(...); // This function modifies a. // . // . // . (More stuff) }; class B : A { // . // . // . (Even more junk) }; main() { B b; b = b.func(); } Of course calling it me isn't neccesarily a good idea, but there still should be one. (I believe this is what Mike Lijewski had in mind all along, but I'm not sure.) Have fun, UUCP: rutgers!umn-cs!ux.acs.umn.edu!hopper (Eric Hopper) __ /) /**********************/ / ') // * I went insane to * / / ______ ____ o // __. __ o ____. . _ * preserve my sanity * (__/ / / / <_/ / <_<__//__(_/|_/ (_<_(_) (_/_/_)_ * for later. * Internet: /> * -- Ford Prefect * hopper@ux.acs.umn.edu /**********************/