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.8 required=5.0 tests=BAYES_00,PLING_QUERY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII X-Google-Thread: 103376,bd360735bb97721d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-05-22 09:25:19 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!nntp.cs.ubc.ca!freenix!gitoyen!news.completel.fr!ciril.fr!cines.fr!univ-lyon1.fr!news.ens-lyon.fr!news.imag.fr!not-for-mail From: Xavier Nicollin Newsgroups: comp.lang.ada Subject: Re: List of packages ?! Date: Thu, 22 May 2003 18:25:18 +0200 Organization: Institut IMAG, Grenoble Message-ID: <3ECCF9EE.A86EAC6B@imag.fr> References: <3ECCD541.50200@alcatel.de> NNTP-Posting-Host: moucherotte.imag.fr Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: trompette.imag.fr 1053620718 32549 129.88.43.82 (22 May 2003 16:25:18 GMT) X-Complaints-To: abuse@imag.fr NNTP-Posting-Date: Thu, 22 May 2003 16:25:18 +0000 (UTC) X-Mailer: Mozilla 4.79 [en] (X11; U; SunOS 5.7 sun4u) X-Accept-Language: en Xref: archiver1.google.com comp.lang.ada:37649 Date: 2003-05-22T18:25:18+02:00 List-Id: Mirko Aigner wrote: > > Hello I am a Student and I got the following problem. > I got c++ Code and now I should reimplement it in Ada. > My Problem is: I have a C++ Class only containing methods. In Ada this > is a package, right ?! See below. > In C++ I can create a list containing this methods-only-class, It's been some time since I last programmed in C++, but I doubt you can create a list of *class(es)*. I guess you create a list of *class instances*, that is, a list of objects. So you should do the same in Ada. Which brings us back to your first question: no, a class is not a package; a class is a type defined in a package. If it has only methods, then the record is empty: package Pack is type T is tagged null record; -- could be private -- the methods: procedure P (X : in T; ...); function F (X : T; ...) return ...; end Pack; Now, you can create a list of objects of type T, that is, a list of instances of the class. Notice that, if your list should contain objects of any "class" including T and its derivatives, then you need accesses (pointers) to T'Class (T'Class is the type whose objects are of type T or of any type derived from T): type PT is access all T'Class; and your list elements are of type PT. I guess this is what you need (otherwise the list would not be very useful!) > is that possible for ada, too ?! Sure, see above. > thanks for the help You're welcome (in general, and in the Ada world, too). -- | Xavier NICOLLIN (mailto:Xavier.Nicollin@imag.fr) -- INPG (ENSIMAG) | VERIMAG -- Centre Equation -- 2, ave. de Vignate -- F-38610 Gi�res