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: 109fba,9ac62ca34a465706 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,9ac62ca34a465706 X-Google-Attributes: gid103376,public From: jsa@organon.com (Jon S Anthony) Subject: Re: on OO differnces between Ada95 and C++ Date: 1996/02/21 Message-ID: #1/1 X-Deja-AN: 140470964 sender: news@organon.com (news) references: <4gbq7q$g08@qualcomm.com> organization: Organon Motives, Inc. newsgroups: comp.lang.ada,comp.lang.c++ Date: 1996-02-21T00:00:00+00:00 List-Id: In article <4gbq7q$g08@qualcomm.com> nabbasi@qualcomm.com (Nasser Abbasi) writes: Use child packages. For example, > Learning_Ada95_OO_features... > ... > Now the C++ way: > > > --------------- account.h ------------------- > class Account > { > public: > typedef int Money_Type; > Money_Type Balance; > int Account_Id; > }; > > -------------- saving_account.h ----------------- > > #include "saving_account.h" > class Saving_Account : public Account > { > public: > Money_Type Interest; > }; > > --------------- main.cpp ----------------- > > #include > #include "saving_account.h" // Notice: no need to include to base class > // Account in account.h > main() > { > Saving_Account The_Saving_Account; > Saving_Account::Money_Type The_Balance; // notice, Money_Type accessed > // through Saving_Account and > // no need to include the > // base class account > > cout << "Balance?"; > cin >> The_Balance; > The_Saving_Account.Balance = The_Balance; > > return 1; > > } Ada version (from your stuff...): > ------------------ account.ads --------------------------- > package Account is > type Money_Type is new integer range 1..100; -- just as an example > type Account_Type is tagged > record > Balance : Money_Type; > Account_Id : Integer; > end record; > end Account; ----------------- Account-Savings.ads ---------------- Package Account.Saving_Account is -- Note: all the stuff in Account is visible here type Saving_Account_Type is new Account.Account_Type with record Interest : Account.Money_Type; end record; end Saving_Account; > --------------- main.adb --------------------------- > with Account.Saving_Account; -- -- Note: visibility of Account comes along with Saving_Account here. with ada.text_io; use ada.text_io; procedure main is package Money_IO is new Ada.Text_IO.Integer_IO(Account.Money_Type); The_Saving_Account : Saving_Account.Saving_Account_Type; The_Balance : Account.Money_Type; begin Money_IO.Get(The_Balance); The_Saving_Account.Balance := The_Balance; end main; -- Jon Anthony Organon Motives, Inc. 1 Williston Road, Suite 4 Belmont, MA 02178 617.484.3383 jsa@organon.com