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, T_FILL_THIS_FORM_SHORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,900edaa189af2033 X-Google-Attributes: gid103376,public From: Andre Spiegel Subject: Re: Ada95 OOP Questions Date: 1996/07/28 Message-ID: #1/1 X-Deja-AN: 171366333 sender: spiegel@berlin.berlin.informatik.uni-stuttgart.de references: <4tf3l4$4hu@masala.cc.uh.edu> organization: University of Stuttgart, Germany newsgroups: comp.lang.ada Date: 1996-07-28T00:00:00+00:00 List-Id: Spasmo writes: > Well after looking at Barnes' Ada95 book and checking out the > OOP sections I noticed that the Objects in Ada95 seem to > consist purely of data, and no methods seem to be involved > so that you have to pass these objects to functions in order > to get stuff done. Am I wrong in this (or did I somehow > miss something again?). Ada Objects "consist" of both data and methods, just like in any other OOP language. Ada calls the methods "primitive subprograms", and they are (roughly) defined as those subprograms "that are explicitly declared immediately within the same package_specification and that operate on the type." (RM95 3.2.3;6) So, to translate your C++ example into equivalent Ada (not just "simulating" it!), you can write package Persons is type Person is tagged private; procedure Walk (P : Person); procedure Talk (P : Person); procedure Eat (P : Person); private type Person is tagged record Age : Integer; -- rather "Natural", I'd suggest -- (C++ doesn't have this) Name : String (1..256); end record; end Persons; What should be pointed out is that C++ and Ada use slightly different abstractions. In C++, you have "classes" and "objects" (but sometimes a class is referred to as an object, too); whereas in Ada you have "packages", "types", "classes of types", and "objects". For a very good discussion of this, see Tucker Taft's answer to Question 5.1 in the Ada Programming FAQ (http://lglwww.epfl.ch/Ada/FAQ/programming.html). Hope this helps, Andre Spiegel University of Stuttgart, Germany