comp.lang.ada
 help / color / mirror / Atom feed
From: b.mcguinness747@gmail.com
Subject: child class of limited_controlled not inheriting data
Date: Fri, 5 Aug 2016 11:59:12 -0700 (PDT)
Date: 2016-08-05T11:59:12-07:00	[thread overview]
Message-ID: <aa30d04a-42be-4b18-b1f5-785377315a15@googlegroups.com> (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


             reply	other threads:[~2016-08-05 18:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-05 18:59 b.mcguinness747 [this message]
2016-08-05 19:20 ` child class of limited_controlled not inheriting data 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
replies disabled

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