* List of packages ?!
@ 2003-05-22 13:48 Mirko Aigner
2003-05-22 16:24 ` Stephen Leake
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Mirko Aigner @ 2003-05-22 13:48 UTC (permalink / raw)
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 ?!
In C++ I can create a list containing this methods-only-class, is that
possible for ada, too ?!
thanks for the help
Mirko Aigner
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: List of packages ?!
2003-05-22 13:48 List of packages ?! Mirko Aigner
@ 2003-05-22 16:24 ` Stephen Leake
2003-05-22 16:25 ` Xavier Nicollin
2003-05-22 18:21 ` Noivet
2 siblings, 0 replies; 5+ messages in thread
From: Stephen Leake @ 2003-05-22 16:24 UTC (permalink / raw)
Mirko Aigner <Mirko.Aigner@alcatel.de> writes:
> 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 ?!
Actually, a C++ class corresponds most closely to an Ada tagged type
in a package.
> In C++ I can create a list containing this methods-only-class, is
> that possible for ada, too ?!
Yes. Here is a "null data class with methods":
package Null_Data_Class is
type Object_Type is tagged null record;
procedure Method_1 (Object : in Object_Type);
procedure Method_2 (Object : in Object_Type);
end Null_Data_Class;
There are several list packages for Ada available; see www.adapower.com.
> thanks for the help
You're welcome.
--
-- Stephe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: List of packages ?!
2003-05-22 13:48 List of packages ?! Mirko Aigner
2003-05-22 16:24 ` Stephen Leake
@ 2003-05-22 16:25 ` Xavier Nicollin
2003-05-23 5:07 ` Mirko Aigner
2003-05-22 18:21 ` Noivet
2 siblings, 1 reply; 5+ messages in thread
From: Xavier Nicollin @ 2003-05-22 16:25 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: List of packages ?!
2003-05-22 13:48 List of packages ?! Mirko Aigner
2003-05-22 16:24 ` Stephen Leake
2003-05-22 16:25 ` Xavier Nicollin
@ 2003-05-22 18:21 ` Noivet
2 siblings, 0 replies; 5+ messages in thread
From: Noivet @ 2003-05-22 18:21 UTC (permalink / raw)
I don't know C++ but if this helps you and if it's that what you
search (list of packages) then look here:
http://www.infeig.unige.ch/support/ada/gnatlb/
or http://www.adahome.com/rm95/rm9x-A.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: List of packages ?!
2003-05-22 16:25 ` Xavier Nicollin
@ 2003-05-23 5:07 ` Mirko Aigner
0 siblings, 0 replies; 5+ messages in thread
From: Mirko Aigner @ 2003-05-23 5:07 UTC (permalink / raw)
Thanks a lot to you Xavier Nicollin, Stephen Leake und Noivet !!
Yes I meant instances of classes!
So I have to define an empty type, and of this empty type I can create
instances which can be hold in a list. Or the accesses of this type can
be hold in a list.
thx again !!
Mirko Aigner
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-05-23 5:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-22 13:48 List of packages ?! Mirko Aigner
2003-05-22 16:24 ` Stephen Leake
2003-05-22 16:25 ` Xavier Nicollin
2003-05-23 5:07 ` Mirko Aigner
2003-05-22 18:21 ` Noivet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox