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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5f0f4bfb0467bb19 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.0.170 with SMTP id 10mr6967279pbf.2.1320954042259; Thu, 10 Nov 2011 11:40:42 -0800 (PST) Path: h5ni24419pba.0!nntp.google.com!news2.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Constructors with multiple inheritance Date: Thu, 10 Nov 2011 20:39:27 +0100 Organization: cbb software GmbH Message-ID: <10xzoyh4rszmr$.s4ir5szcahvp.dlg@40tude.net> References: <11513972.2788.1317325228383.JavaMail.geo-discussion-forums@yqnv12> <1rj1mmkvwud1d.dzqoy4jhdfca$.dlg@40tude.net> <4976045.4489.1317352313370.JavaMail.geo-discussion-forums@yqjw35> <2pu3h5hqltxi$.ze4yrf1f2y8z.dlg@40tude.net> <23774546.1654.1317391464047.JavaMail.geo-discussion-forums@yqnk41> <1gnrks1djlaok.1k0r5f8z9ylfx.dlg@40tude.net> <21605158.153.1320805494018.JavaMail.geo-discussion-forums@yqiu15> <6366850.176.1320896821400.JavaMail.geo-discussion-forums@yqcm23> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: /UEGvvv3iJTp1sBsj2v2og.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news2.google.com comp.lang.ada:14397 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2011-11-10T20:39:27+01:00 List-Id: On Thu, 10 Nov 2011 11:16:24 -0700, Jeffrey Carter wrote: > On 11/09/2011 08:47 PM, Rego, P. wrote: >> >> class Par_Class { >> public: >> Par_Class (int aValue, const char *aName); >> >> private: >> int theValue; >> char *theName; >> }; > > private with Ada.Strings.Unbounded; > > package Par is > type Class is private; > > function Create (Value : in Integer; Name : in String); > private -- Par > type Class is record > Value : Integer := Integer'First; > Name : Ada.Strings.Unbounded.Unbounded_String; > end record; > end Par; > > package body Par is > function Create (Value : in Integer; Name : in String) is > -- null; > begin -- Create > return Class'(Value => Value, > Name => Ada.Strings.Unbounded.To_Unbounded_String (Name) ); > end Create; > end Par; > > No need for tagged types or access types for this example. No need in unbounded strings either: type Class (<>) is private; function Create (Value : in Integer; Name : in String) return Class; private type Class (Length : Natural) is record Value : Integer := Integer'First; Name : String (1..Length); end record; function Create (Value : in Integer; Name : in String) return Class is begin return (Length => Name'Length, Value => Value, Name => Name); end Create; IMO, unbounded strings should be used only in two cases: 1. The container type must be constrained (e.g. to place its objects into arrays etc) 2. The component is varying during object's life. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de