comp.lang.ada
 help / color / mirror / Atom feed
From: Gerd <GerdM.O@t-online.de>
Subject: Re: Translating C++ class types into Ada tagged types?
Date: Wed, 18 Jul 2007 03:27:51 -0700
Date: 2007-07-18T03:27:51-07:00	[thread overview]
Message-ID: <1184754471.663273.202270@m37g2000prh.googlegroups.com> (raw)
In-Reply-To: <YYydnZywPr0puw7bnZ2dnUVZ_t6qnZ2d@comcast.com>


tmo...@acm.org schrieb:
> You can force the user to give an initial age by
>
>  package Animals is
>     type Cat(Initial_Age : Positive) is tagged private;
>  ...
>     type Cat(Initial_Age : Positive) is tagged record
>        Age : Positive := Initial_Age;
>     end record;
>  ...
>     Frisky : Animals.Cat(Initial_Age => 0);
> If you want the initialization to be significantly more complicated
> than that, you can make type Cat controlled, with Initialize and
> Finalize procedures.


Is this dot notation a new feature of Ada 2005? As far as I know (my
own trials, long ago) it is not possible with Ada95.
     Frisky : Animals.Cat(Initial_Age => 0);


Lets assume the following code (maybe not syntactically correct),
would it work this way, or how would it be done?

package Vehicle is
  type Car is tagged record
    NrWheels : Positive := 4;
  end record;

 function Wheels (c : Car'Class) return Positive;
end Vehicle;

with Vehicle
package TransportCar is
  type BigCar is new Car with
    record
       Seats : Positive;
    end record;

  function Seats (bc : BigCar) return Positive;

end TransportCar;

...

with Car;
with TransportCar;

MyCar : TransportCar;

...

nrseat := MyCar.Seats;
nswheels := MyCar.Wheels;

Does the compiler know where the functions come from, or must I write
it like in

nrwheels := Car.Wheels (MyCar);
nrseats := TransportCar.Seat(MyCar)




  reply	other threads:[~2007-07-18 10:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-10  1:39 Translating C++ class types into Ada tagged types? markus034
2007-07-10  2:12 ` jimmaureenrogers
2007-07-10  3:26   ` markus034
2007-07-10  6:27     ` tmoran
2007-07-18 10:27       ` Gerd [this message]
2007-07-18 11:58         ` Georg Bauhaus
2007-07-10  8:07   ` Georg Bauhaus
2007-07-16  5:47     ` markus034
2007-07-16  7:30       ` Georg Bauhaus
2007-07-16 17:35         ` markus034
2007-07-10  9:19 ` Patrick
2007-07-11 20:09   ` markus034
2007-07-11 23:15     ` Jeffrey Creem
2007-07-12  5:46   ` vgodunko
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox