From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,20bd571d6106b9a4,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-13 12:45:39 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!headwall.stanford.edu!feeder.via.net!newshub2.rdc1.sfba.home.com!news.home.com!e420r-sjo4.usenetserver.com!news-out.usenetserver.com!e420r-atl2.usenetserver.com.POSTED!not-for-mail From: "Anthony E. Glover" Newsgroups: comp.lang.ada Subject: How To Represent Class Wide Constants X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2462.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2462.0000 Message-ID: X-Complaints-To: abuse@usenetserver.com X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly. NNTP-Posting-Date: Wed, 13 Jun 2001 12:06:34 EDT Organization: WebUseNet Corp. - ReInventing The UseNet Date: Wed, 13 Jun 2001 11:10:14 -0500 Xref: archiver1.google.com comp.lang.ada:8685 Date: 2001-06-13T11:10:14-05:00 List-Id: 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