Q enums in date.h

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Q enums in date.h

Gilbert Peffer
Hi,
Yes, I am currently delighting myself with reading code. My preferred
pass-time ;-) I will send my questions and comments individually, as I go
along, unless you prefer me to put all the stuff together in one mail.

Enums: Do you mind explicitly assigning numbers to enum variables? I prefer
not to leave it up to the compiler, and it makes it more readable for the
less-versed C++ people. This would avoid the confusion of the first variable
being 0 or 1 in an enum list. And (oh no, again) I love to stack things...

    enum Weekday { Saturday = 1,
                   Sunday   = 2,
                   ...
                   Friday   = 7 } ;

Is it common to set Saturday as the first day in the week? Just that I can't
remember...

Regards
Gilbert

____________________________________________

Gilbert Peffer
Project Manager
Finance, IT & Engineering
International Centre for Numerical Methods in Engineering (CIMNE)
Building C1 -  North Campus UPC
Gran Capità s/n
08034 Barcelona, Spain

Movil: +34 626 386 652
Tel:   +34 93 401 6038
       +34 93 401 6035
Fax:   +34 93 401 6517
E-mail: [hidden email]
Web:    www.cimne.upc.es



Reply | Threaded
Open this post in threaded view
|

Re: Q enums in date.h

Luigi Ballabio-3
At 12:11 PM 12/21/00 +0100, Gilbert Peffer wrote:
>Hi,
>Yes, I am currently delighting myself with reading code. My preferred
>pass-time ;-) I will send my questions and comments individually, as I go
>along, unless you prefer me to put all the stuff together in one mail.

One mail at the time is fine with me. Kind of keeps me company :)

>Enums: Do you mind explicitly assigning numbers to enum variables? I prefer
>not to leave it up to the compiler, and it makes it more readable for the
>less-versed C++ people.

Agreed, as far as I'm concerned.

>    enum Weekday { Saturday = 1,
>                    Sunday   = 2,
>                    ...
>                    Friday   = 7 } ;
>
>Is it common to set Saturday as the first day in the week? Just that I can't
>remember...

I'll take the blame for this.
I think I assigned 0 to Saturday so that dayOfWeek() was simply
         return Weekday(theSerialNumber%7)
instead of
         return Weekday((theSerialNumber-1)%7)
In short, I must have had a nail in my head :)

Bye,
         Luigi