On 10 May 2005 01:34:51 -0700,
cm**********@btinternet.com wrote:
Hi there,
I keep finding myself getting inconsistent with naming conventions for
things like member variables, class names etc and I just want to find
something that suits me and stick to it. I am wondering if there are
any naming conventions around that are deemed suitable by the general
C++ community. I have googled around and I can't find much - mostly
long lists of hungarian-like prefixes which is not really what I'm
after.
I searched the groups also and found lots of (lengthy) discussions on
the topic and all i want really is just to read a few guidelines to get
some ideas, pick the ones I like and use that. I've looked around in
books like C++ Coding Standards (Sutter), Effective C++ (Meyers) but
they talk about coding practices rather than naming.
Caroline Middlebrook
What everyone else said. Except for leading underscores, which are a
no-no, it's probably a toss-up in the end.
Leading underscores are to be avoided in user code. These are reserved
for names used in the standard libraries or built-in names defined by
the compiler or its other libraries ("reserved for the implementation"
is how it is worded in the standard).
The company I used to work for had lots of code where private member
variables were always written with leading underscores because the
company's previous coding guidelines said to do so. Wow, that was a
job when we realized that we should change it ... we went in and
tacked an "m" on in front of the leading underscore because it
amounted to the least amount of typing and still conveyed the
necessary information ("m_" for member).
I don't like trailing underscores either because they are often
overlooked in the implementation code. They have a tendency to get
confused with local variables spelled the same except for the trailing
underscore.
--
Bob Hairgrove
No**********@Home.com