Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!milano!cadillac!vaughan@mcc.com From: vaughan@mcc.com (Paul Vaughan) Newsgroups: comp.lang.c++ Subject: Re: Need `set before used' warning Keywords: c++, warning Message-ID: <11745@cadillac.CAD.MCC.COM> Date: 3 Oct 90 19:12:04 GMT References: <2@mtnmath.UUCP> <1990Sep27.001259.25809@relay.wpd.sgi.com> <195@c.procase.UUCP> Sender: news@cadillac.CAD.MCC.COM Reply-To: vaughan@mcc.com (Paul Vaughan) Organization: MCC VLSI CAD Program Lines: 23 In-reply-to: roger@procase.UUCP (Roger H. Scott) From: roger@procase.UUCP (Roger H. Scott) I would like to reinforce the suggestion that *all* class members be *initialized* in constructors using *initialization* (not assignment) syntax. While this is not always possible (due to the need to do non-trivial computation in order to generate the actual member values), it often possible. I find that many of my constructors have empty "{}" bodies, since all they do is initialize members and subclasses. I've been tending to use the initialization form more and more, but I don't really have a good reason for why I should do that. A simple argument against using the initialization form is that you have to initialize members for each constructor, where assignments are conveniently swept into an init function called by each constructor. And as is pointed out above, you have to decide first whether it's even feasible. So, how do you (anybody who is reading this) justify this opinion? Paul Vaughan, MCC CAD Program | ARPA: vaughan@mcc.com | Phone: [512] 338-3639 Box 200195, Austin, TX 78720 | UUCP: ...!cs.utexas.edu!milano!cadillac!vaughan