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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,fc52c633190162e0 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Newsgroups: comp.lang.ada Subject: Re: why learn C? References: <1172144043.746296.44680@m58g2000cwm.googlegroups.com> <1172161751.573558.24140@h3g2000cwc.googlegroups.com> <546qkhF1tr7dtU1@mid.individual.net> <5ZULh.48$YL5.40@newssvr29.news.prodigy.net> <1175215906.645110.217810@e65g2000hsc.googlegroups.com> <1175230352.808212.15550@e65g2000hsc.googlegroups.com> <1175236212.771445.135460@y66g2000hsf.googlegroups.com> <1175308871.266257.77460@e65g2000hsc.googlegroups.com> <1175501602.127760.186120@q75g2000hsh.googlegroups.com> From: Markus E Leypold Organization: N/A Date: Thu, 12 Apr 2007 20:05:35 +0200 Message-ID: <1yveg1eads.fsf@hod.lan.m-e-leypold.de> User-Agent: Some cool user agent (SCUG) Cancel-Lock: sha1:sNzBdEaeU2MsYyUaF9FVqG3ylZs= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 88.72.204.82 X-Trace: news.arcor-ip.de 1176400691 88.72.204.82 (12 Apr 2007 19:58:11 +0200) X-Complaints-To: abuse@arcor-ip.de Path: g2news1.google.com!news2.google.com!news1.google.com!news.glorb.com!txtfeed1.tudelft.nl!tudelft.nl!txtfeed2.tudelft.nl!multikabel.net!feed20.multikabel.net!news.germany.com!news.unit0.net!newsfeed.arcor-ip.de!news.arcor-ip.de!not-for-mail Xref: g2news1.google.com comp.lang.ada:14996 Date: 2007-04-12T20:05:35+02:00 List-Id: Hyman Rosen writes: > kevin cline wrote: >> Preprocessor macros are quite out of fashion for C++ programming. > > Unfortunately so. They're good for quite a bit of things, > especially when you want to code a little "database" table > of properties to be "queried" for the implementation. > > #define QuotesTableData(IMPL) \ > IMPL(stock, "Security Name", string) \ > IMPL(date, "Quote Date", time_t) \ > IMPL(bid, "Bid Price", double) \ > IMPL(ask, "Ask Price", double) > > struct QuotesTable { > #define QuotesEnumImpl(name, title, type) name, > enum { QuotesTableData(QuotesEnumImpl), N }; > #define QuotesMembersImpl(name, title, type) type m_##name; > QuotesTableData(QuotesMembersImpl) > #define QuotesPropertiesImpl(name, title, type) \ > type get_##name() const { return m_##name; } \ > void set_##name(const type &v) { m_##name = v; } \ > string title_##name() const { return title; } > QuotesTableData(QuotesPropertiesImpl) > }; Without trying to understand ypur example in depth: This is -- of course -- only necessary because C/C++ has no way to specify a constant array (i.e. a "array literal"). Regards -- Markus