Re: C++ Coding Style
Chris Frey <[email protected]> Sun, 21 Dec 2003 16:31:01 -0500
| Newsgroups | gmane.linux.zynot.devel |
|---|---|
| Message-ID | <[email protected]> |
On Sun, Dec 21, 2003 at 02:20:27PM +0000, Galik wrote: > >>'*' attached to typename, no spaces in declaration: > >> > >>~ const char* cstring; > >>~ int (*pfunc)(int, int); > >> > >> > > > >This I disagree with because it leads to confusion in declarations of > >lists of pointers. Which is correct? > > > > char* ptr1, ptr2; > >or > > char *ptr1, *ptr2; // correct > > > >Keeping the star with the variable keeps things clear. > > > > > > > Bah! This is the only construct where placing '*' by the identifier > makes sense. It is also a terrible thing to do. All declarations should > appear on a separate line. See Bjarne Stroustrup's The C++ Programming > Language... Do you have a page number? I don't recall him specifically advocating one or the other, but I may have missed it. I would like to hear his reasoning on it. Also, why are lists of variables a terrible thing to do? I'm not asking to cause a flame war, I really want to know. I gave a practical reason for mine... :-) - Chris