Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!husc6!think!ames!elroy!gryphon!sarima From: sarima@gryphon.COM (Stan Friesen) Newsgroups: comp.lang.c++ Subject: Re: constructor calls constructor? Keywords: constructors, this Message-ID: <16224@gryphon.COM> Date: 28 May 89 16:19:23 GMT References: <601@rna.UUCP> Reply-To: sarima@gryphon.COM (Stan Friesen) Organization: Trailing Edge Technology, Redondo Beach, CA Lines: 26 In article <601@rna.UUCP> kc@rna.UUCP (Kaare Christian) writes: >A question, if you please. > >I have a class that has several constructors. >[Examples deleted] >All of these constructors have some mundane chores that must be accomplished, >plus there are extra chores for those that take extra arguments. What I tried >to do was have the "parameter taking" constructors all call the >parameterless constructor. > >This didn't work, the call to X() created a new object, it didn't >initialize the current object. > >>[Other failed approach deleted] >Is there a way for one constructor to call another, simply to have >some chores performed, while avoiding real construction? (I know I can >have all the constructors call some helper function, but that >seems too roundabout.) > What's so round-about in using a helper function? Especially since the helper can be made a private function, used only in constructors? It is also quite readable. -- Sarima Cardolandion sarima@gryphon.CTS.COM aka Stanley Friesen rutgers!marque!gryphon!sarima Sherman Oaks, CA