comp.lang.ada
 help / color / mirror / Atom feed
From: rieachus@comcast.net
Subject: Re: child class of limited_controlled not inheriting data
Date: Sat, 6 Aug 2016 12:00:21 -0700 (PDT)
Date: 2016-08-06T12:00:21-07:00	[thread overview]
Message-ID: <a79aaf10-8a21-4cc6-8255-20d7e879ed9c@googlegroups.com> (raw)
In-Reply-To: <aa30d04a-42be-4b18-b1f5-785377315a15@googlegroups.com>

On Friday, August 5, 2016 at 2:59:16 PM UTC-4, b.mcgui...@gmail.com wrote:
> I defined a base class as
... 
>   function To_Date (days : Integer; fraction : Real) return Date;
>   function To_Date (time_string : String)            return Date;
... 
> What is wrong here?

Actually you have the solution right there, except that you will want to override To_Date for your Julian date abstraction to correct the times.  Julian dates, at least in astronomical use, begin at noon GMT.  (I could chide you for not having a timezone parameter everywhere needed, but I am going to assume that you will add that after you get the basics working. ;-)

There is a bit of magic necessary in your overriding of To_Date.  You need to call the original function:

function To_Date(days : Integer; fraction : Real) return Julian_Date is
  Jdays: Integer := days;
  Jfraction: Real := fraction;
begin
  -- fix up Jdays and Jfraction here.
  return sofa.time.two_part_date.To_Date(Jdays,Jfraction) with null;
end To_Date;

I would probably use a fixed point type, Milliseconds, instead of your Float fraction, but even if I could convince you why it is better, it probably is not worth changing, unless you are pointing a really big telescope at asteroids.


      parent reply	other threads:[~2016-08-06 19:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]
replies disabled

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