comp.lang.ada
 help / color / mirror / Atom feed
From: "Anthony E. Glover" <aglover@elmco.com>
Subject: How To Represent Class Wide Constants
Date: Wed, 13 Jun 2001 11:10:14 -0500
Date: 2001-06-13T11:10:14-05:00	[thread overview]
Message-ID: <ecMV6.9817$FX1.310930@e420r-atl2.usenetserver.com> (raw)

What is the best approach for representing class wide constants
within Ada95? Specifically, I have classes that contain values that
are read in from a data file and remain unchanged throught the
life of the program. They are the same for all objects of the class.
Also, in some cases, sub-classes need to be able to override the
values of the parent class with their own set of values. Currently
I am implementing them as primitive functions of the class and
overriding the function within the sub-class. I also default the
object to a null record that way I can retrieve the value without
having to pass an object. See below:

package MyClass is

    type MyClass_Type is .....

    function Null_Object return MyClass_Type;

    function Constant1( Object : MyClass_Type := Null_Object ) return Float;

etc...

I can then invoke MyClass.Constant1 to retrieve the value for that constant.

Can this been done in a better way?

Thanks for any help.
Tony







                 reply	other threads:[~2001-06-13 16:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
replies disabled

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