comp.lang.ada
 help / color / mirror / Atom feed
* child class of limited_controlled not inheriting data
@ 2016-08-05 18:59 b.mcguinness747
  2016-08-05 19:20 ` Jeffrey R. Carter
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: b.mcguinness747 @ 2016-08-05 18:59 UTC (permalink / raw)


I defined a base class as


with Ada.Float_Text_IO;
with Ada.Finalization;

package sofa.time.two_part_date is
  type Date is new Ada.Finalization.Limited_Controlled with private;

  function To_Date (days : Integer; fraction : Real) return Date;
  function To_Date (time_string : String)            return Date;

  function "<"  (left, right : Date) return Boolean;
  function "<=" (left, right : Date) return Boolean;
  function "="  (left, right : Date) return Boolean;
  function ">=" (left, right : Date) return Boolean;
  function ">"  (left, right : Date) return Boolean;

  procedure Add_Days (this : in out Date; days : in Integer; fraction : in Real);

  function Get_Day_Count (this : Date)    return Integer;
  function Get_Day_Fraction (this : Date) return Real;
  function To_Real (this : Date)          return Real;
  function To_String (this : Date)        return String;

private
  type Date is new Ada.Finalization.Limited_Controlled with record
    day_count    : Integer;
    day_fraction : Real;    -- Normalized to 0.0 <= x < 1.0
  end record;

  overriding procedure Initialize (this: in out Date);
  overriding procedure Finalize   (this: in out Date);

  procedure Normalize (day_count : in out Integer; day_fraction : in out Real);
end;


(It's Limited_Controlled because I want to force day_fraction to be normalized when objects of the class are created.)

Then I defined a child class as


with sofa.time.two_part_date;

package sofa.time.Julian_Day_Numbers is
  type Julian_Day_Number is new sofa.time.two_part_date.Date with null record;

  function To_Julian_Day_Number (time : Instant) return Julian_Day_Number;
  function To_Calendar_Date (this : Julian_Day_Number; calendar : Calendar_Type := GREGORIAN; zone : Time_Zone_Number := 0) return Instant;
  function To_Milliseconds (this : Julian_Day_Number) return Integer;

end sofa.time.Julian_Day_Numbers;


When I try to compile the child class, I get error messages such as

sofa-time-julian_day_numbers.adb:77:79: "day_count" is not a component of type "Julian_Day_Number" defined at sofa-time-julian_day_numbers.ads:4

indicating that the child class is not inheriting the data from the parent class.

What is wrong here?

Thanks.

--- Brian


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-08-06 19:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-05 18:59 child class of limited_controlled not inheriting data b.mcguinness747
2016-08-05 19:20 ` Jeffrey R. Carter
2016-08-05 19:36 ` Simon Wright
2016-08-05 19:37 ` Dmitry A. Kazakov
2016-08-05 19:42 ` G.B.
2016-08-05 20:26 ` b.mcguinness747
2016-08-05 20:47   ` Dmitry A. Kazakov
2016-08-06 19:00 ` rieachus

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