* How To Represent Class Wide Constants
@ 2001-06-13 16:10 Anthony E. Glover
0 siblings, 0 replies; only message in thread
From: Anthony E. Glover @ 2001-06-13 16:10 UTC (permalink / 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-06-13 16:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-13 16:10 How To Represent Class Wide Constants Anthony E. Glover
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox