KPB,
Yes, it took me a while to recalibrate to this small shift of putting the
const after the type. The section of 1.4 in that book on syntactical
substitution principle was quite interesting in that it shows a case where
putting the const *before* the type can actually cause confusion if someone
thinks you can just textually replace a typedef.
Also in favor of putting the const after the type it modifies is that is how
compilers view it so if you wrote a function void func(const char* p), and
then viewed the symbols generated by the compiler using what every binary
utils are available for your compiler, you will see that the compiler thinks
of that function as void func(char const* p). Can be usesful to think this
way to decipher compiler error messages. Matter of taste of course but
interesting to view if both ways.
Regards,
Bruce
"KPB" <kw@foo.net> wrote in message news:At***************@fe11.lga...
I have an O'Reilly Safari Online subscription. I decided to check out
this book(C++ Templates) and am half way through it.
For those of you who read this one, I don't know what you thought about
section 1.4 (Some remarks about Programming Style) but I thought it was
weird at first.
You know? Writing an init statement like this:
int const N = 100;
instead of like this (which I've always done)
const int N = 100;
I have to say though, the style outlined in the book has really grown on
me. It really makes sense when you throw a reference token or pointer
token in there. Just read it from right to left
char const* const p = 0;
I know from reading this right to left it's a "constant pointer" to a
"constant character".
Using this way as I always have done:
const char* const p = 0;
I always had to think about it for a second.
I see the authors' points about this. Did any of you are do you still
think it's *weird*?
Just curious.
KPB