Re: Lookup Table
From: Francis Glassborow (francis_at_robinton.demon.co.uk)
Date: 05/05/04
- Next message: David White: "Re: Trouble implementing Singleton Pattern"
- Previous message: Paul: "Re: C++ Conversion functions for pointers"
- In reply to: Mike Wahler: "Re: Lookup Table"
- Next in thread: Arthur J. O'Dwyer: "Re: Lookup Table"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 4 May 2004 23:55:53 +0100
In message <h8Slc.6912$Hs1.3926@newsread2.news.pas.earthlink.net>, Mike
Wahler <mkwahler@mkwahler.net> writes
>class X
>{
>public:
> typedef enum
> {red, green, yellow, blue, magenta, cyan, colour_count} tColour;
However this is C++ so drop that typedef and write
enum colour{red, green, yellow, magenta, cyan, colour_count};
>
>protected:
> const static int r[colour_count];
Wherever you choose to put count it is much more normal to place static
first because that is the most important element in the declaration,
distinguishing these as class variables as opposed to member ones.
Personally I would prefer:
static int const r[colour_count];
but
static const int r[colour_count];
is OK and preferred by many others.
I am also a little curious about the organisation of this into three
separate tables. My personal choice would be:
static int const rgb_mix[colour_count][3];
// 3 does not seem too magic here
and then intialise it as below
> const static int g[colour_count];
> const static int b[colour_count];
>};
>
int const X::rgb_mix[colour_count][3] = {{255,0,0},
{0, 255, 0},
{0, 255, 0},
{255, 255, 0},
{0, 0, 255},
{255, 0, 255},
{0, 255, 255}
}
and what happened to black and white?
-- Francis Glassborow ACCU Author of 'You Can Do It!' see http://www.spellen.org/youcandoit For project ideas and contributions: http://www.spellen.org/youcandoit/projects
- Next message: David White: "Re: Trouble implementing Singleton Pattern"
- Previous message: Paul: "Re: C++ Conversion functions for pointers"
- In reply to: Mike Wahler: "Re: Lookup Table"
- Next in thread: Arthur J. O'Dwyer: "Re: Lookup Table"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]