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-Thread: 109fba,cd8ed9115942852f X-Google-NewGroupId: yes X-Google-Thread: 103376,b92b95c9b5585075 X-Google-NewGroupId: yes X-Google-Attributes: gid4f1905883f,gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news.glorb.com!news-out.readnews.com!transit3.readnews.com!s09-11.readnews.com!unm2.readnews.com.POSTED!not-for-mail X-Trace: DXC=b2I>fTn7P`LM=?cF8X300BTLaYZ5A`]3G]UVm4ab0o;Ok`R^3PKYWgCSUXD^Wd\CQL`LSM[oHHnYOi4hBgTdKg6C39AYQN6>3K@=g7J85eQVa@ X-Complaints-To: abuse@usenet-news.net Date: Fri, 12 Aug 2011 09:15:22 -0400 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 Newsgroups: comp.lang.c++,comp.lang.ada Subject: Re: Why use C++? References: <1e292299-2cbe-4443-86f3-b19b8af50fff@c29g2000yqd.googlegroups.com> <1fd0cc9b-859d-428e-b68a-11e34de84225@gz10g2000vbb.googlegroups.com> <9ag33sFmuaU1@mid.individual.net> <1d8wyhvpcmpkd.ggiui9vebmtl.dlg@40tude.net> <150vz10ihvb5a.1lysmewa1muz4$.dlg@40tude.net> <1q4c610mmuxn7$.1k6s78wa0r8fj.dlg@40tude.net> <4e44e50a$0$7619$9b4e6d93@newsspool1.arcor-online.net> In-Reply-To: <4e44e50a$0$7619$9b4e6d93@newsspool1.arcor-online.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4e45276d$0$13269$a8266bb1@newsreader.readnews.com> Organization: readnews.com - News for Geeks and ISPs NNTP-Posting-Host: 0618e502.newsreader.readnews.com Xref: g2news2.google.com comp.lang.c++:92617 comp.lang.ada:21541 Date: 2011-08-12T09:15:22-04:00 List-Id: On 8/12/2011 4:32 AM, Georg Bauhaus wrote: > #define RGB_LIMIT 3 > > typedef unsigned char Intensity; > enum RGB {Red, Green, Blue}; > typedef Intensity Pixel[RGB_LIMIT]; I might do this instead as typedef unsigned char Intensity; enum RGB_Index { Red, Green, Blue, N_RGB_Index }; typedef Intensity Pixel[N_RGB_Index]; which avoids the need for a macro and ties the number of intensities in the array directly to its enumerated index. > switch (1) { case 0: break; case CHAR_BIT == 8: break; } Oh, that's cute! It's going right into my bag of tricks :-) You don't need the breaks, though: switch (1) { case 0: case CHAR_BIT == 8: ; } And with C++, you don't need executable code: // Probe template template struct probe { }; template <> struct probe { typedef int t; }; // test for 8-bit char typedef probe::t is_char_8_bit; > If I am a beginner, what is the number of technicalities I > must know it order to understand the second way of declaring > things? A few; of course, when I was a complete Ada beginner (not that I'm much more than that now) I was always thrown by the use of apostrophes as attribute designators. When I see for Intensity'Size use 8; it makes me want to go off searching for where the string ends and trying to figure out what's going on. I also don't know that a beginner finds the notion of an enumerated type declared as an array index to be immediately obvious. > (I'll leave out that the declare-like-used rule in typedef is > confusing many. Maybe that's because the typdef-ed name isn't in some > fixed position in the typedef.)