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=0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00, PP_MIME_FAKE_ASCII_TEXT autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,c6ca9cbe17b867c4 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!news.glorb.com!Spring.edu.tw!news.nctu.edu.tw!feeder.seed.net.tw!attdv1!ip.att.net!newsfeed1.global.lmco.com!svlnews.lmms.lmco.com!not-for-mail From: "Xenos" Newsgroups: comp.lang.ada Subject: Re: access & address Date: Fri, 15 Oct 2004 13:09:01 -0400 Organization: Hades Message-ID: References: <1c2f5137.0410140105.66fdb23e@posting.google.com> <1347924.5V7QhTSfdI@linux1.krischik.com> <2t7jm8F1sp752U1@uni-berlin.de> <1982479.VT7X1MC7VE@linux1.krischik.com> <0hSbd.106246$dP1.397440@newsc.telia.net> NNTP-Posting-Host: 158.187.64.144 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 Xref: g2news1.google.com comp.lang.ada:5284 Date: 2004-10-15T13:09:01-04:00 List-Id: "Bj�rn Persson" wrote in message news:0hSbd.106246$dP1.397440@newsc.telia.net... Xenos wrote: >> If you define an enum such as: >> >> enum month {First_Month = 0, Last_Month = 12}; >> >> The C++ standard says that any value within the range is valid (actually its >> any value less than or equal to the closed power of 2, not less than 12, but >> close enough). >So I can assign 15 to it? Which month would that be? And which month is >number 0? That's not what I call "close enough". No, perhaps my example was a little too simplicistic, or you knew what I meant and just choose to be snide. By "close enough" I was referring to my explination of the standard. 0 was a type-o, and beg your forgiveness for making one. I know that when I am writing in Ada, I magically never make one and you must not either. First, you can't assign 15 to it, you can't assign an integer to an enum in C++ without an explicit cast. My point was that just specifying the upper bound is good enough to guarantee the language internally uses an integer type with a big enough range to accomodate you. If I were to actually do months is would be something like: enum months {january, february, .... , december}; and not use numbers. The example was just to show you how you could make the template types unique without needing to define another class. The ranged class should by defined in such a way that only its base type T (in this case months) is castable to it. regards.