From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b0d569080889afd6 X-Google-Attributes: gid103376,public From: Richard D Riehle Subject: Re: A question for my personal knowledge. Date: 1999/05/18 Message-ID: <7hsh9g$rjp@sjx-ixn4.ix.netcom.com>#1/1 X-Deja-AN: 478829968 References: <1VEZ2.1515$I51.88140@carnaval.risq.qc.ca> <37372A84.641F2133@bigfoot.com> <7h8oe8$2js$1@cf01.edf.fr> <37382B0C.A95B6745@bigfoot.com> <7h9o21$9v4$1@nnrp1.deja.com> <7h9pei$aut$1@nnrp1.deja.com> <373AC668.4824FF07@decada.enet.dec.com> <7hfctj$1kb4@drn.newsguy.com> <7hqcni$p8r@sjx-ixn1.ix.netcom.com> Organization: Netcom X-NETCOM-Date: Tue May 18 1:07:12 PM PDT 1999 Newsgroups: comp.lang.ada Date: 1999-05-18T13:07:12-07:00 List-Id: In article , Hyman Rosen wrote: >Richard D Riehle writes: >> For example, a properly designed C++ class requires at least one >> constructor, a copy constructor, overloading of assignment, and a >> destructor. > >That is completely untrue, if you mean that the programmer must supply >those methods, since the compiler will write all of these for you if >you don't write them yourself. You only need your own if the default >ones are not suitable for your purposes. But for those cases, you would >have to do the same in Ada, I imagine. While it is true that a C++ compiler may create _all_ of these for you, it would be a rare class where there was no constructor defined in the public part. I have seen C++ classes where no constructor was defined in which the constructor was inherited from an ancestral class. Not common. Destructors are more often defaulted to the one created by the compiler. This is sometimes the source of an error in the design of a class. An even more interesting source of errors is the failure to create a copy constructor or overload assignment. You are correct that the compiler will create these for you. The question is when to create your own instead of accepting the default created by the compiler. The answer to this question is often non-trivial. In Ada, a creation of an object is a simple declaration. Since Ada allows initialization of object components, no initializor list is required, unless the type has a discriminant. An Ada designer has some options not available to the C++ programmer when choosing which level of abstraction to incorporate into a design. A prolonged discussion of these is beyond the scope of a short note on this forum. I wonder if the closing words of your reply, "I imagine," suggest that further study of Ada would illuminate some of the points better than I could do in this brief space. As to comparing the languages, such comparisons are nearly always fruitless. People have their preferences. They will find whatever features, syntax, and semantic horseradish that best supports their personal point-of-view. This is as true of me as it no doubt is of you. I use both languages, Ada and C++. My personal preference is Ada. I find it better suited to complex design of large-scale safety critical software. Perhaps my preference is a function of unbridled bigotry. So be it. But I have taken the trouble to study and use both languages, so I think my bigotry is softened by my experience. Have you taken the trouble to study Ada? Richard Riehle richard@adaworks.com http://www.adaworks.com