Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!wugate!uunet!ncrlnk!ncratl!brown From: brown@ncratl.Atlanta.NCR.COM (Kyle Brown) Newsgroups: comp.lang.c++ Subject: variable declaration Keywords: variables, objects, optimization Message-ID: <953@ncratl.Atlanta.NCR.COM> Date: 12 Sep 89 14:47:44 GMT Organization: NCR Corporation, E&M Atlanta Lines: 15 Hi Folks. Here's a little question that's come up as I try to put together a style guide for C++ programming. In standard C (and other block-structured languages) it's common to declare all variables in a block at the beginning of your program. However, in C++ it is often useful to declare some variables close to their first point of use. (See Stroustroup 1986 for a discussion) For example, some object constructors have parameters that may not be defined at the beginning of a block, etc. Has anybody developed any style rules for this? I'm especially worried about the tradeoff of readability for optimization. (This becomes a real issue in loop indices) Any pointers to information on general C++ style (other than Stroustroup and Wiener and Pinson, which I have) would be helpful.