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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,103b407e8b68350b X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-06 19:14:42 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!HSNX.atgi.net!newsfeed.frii.net!newsfeed.frii.net!nntp5.savvis.net!uunet!dfw.uu.net!ash.uu.net!spool0900.news.uu.net!reader0902.news.uu.net!not-for-mail Date: Mon, 06 Jan 2003 22:14:35 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3a) Gecko/20021212 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Anybody in US using ADA ? One silly idea.. References: <3E147D79.2070703@cogeco.ca> <4519e058.0301031434.51a0c880@posting.google.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1041909275.331518@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1041909276 reader2.ash.ops.us.uu.net 12000 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:32656 Date: 2003-01-06T22:14:35-05:00 List-Id: Wes Groleau wrote: > Does C++ have subtypes and derived types? No. The only thing of this type available is class inheritance. > But I wish I could > define things like 'First and 'Last when I create a > private type for which they are meaningful. In C++, you can set up arbitrary "attributes" of this sort by using a technique called traits. You define a class template, and then specialize it for your type. Whether to have a common fallback value or not is up to you. Eg., template struct DoesIt; struct Dog; struct Cat; struct AEIOU; template<> struct DoesIt { enum { Howl = 1, Yowl = 0, Vowel = 0 }; }; template<> struct DoesIt { enum { Howl = 0, Yowl = 1, Vowel = 0 }; }; template<> struct DoesIt { enum { Howl = 0, Yowl = 0, Vowel = 1 }; };