In article <11**********************@g47g2000cwa.googlegroups .com>,
Kristo <kr*******@gmail.com> wrote:
Ook wrote: Is there any kind of naming convention for accessor and modifiers? What I've
been doing is something like this:
Naming conventions are a coding standards concept, which is something
not covered by the C++ standard. I believe the FAQ has links to a few
good ones that you could take a look at.
// accessor
int getSize();
// Modifier
void setSize( int newsize);
Sure, a lot of people name accessor/modifier functions this way.
private:
int _size;
Now *that* isn't allowed. Leading underscores are reserved for the
implementation. I suggest changing that to size_.
Not quite, there is some rules about how to use leading underscores,
and the above does not violate them as per any requirements of
Standard C++. However, it may violate other standards, or some
other convention, and besides, it's easier to not have to remember
the Standard C++ rules, so in short, the above is probably best
avoided, and instead some other convention be used (like trailing _'s)
if indeed some convention at all is necessary.
--
Greg Comeau / Celebrating 20 years of Comeauity!
Comeau C/C++ ONLINE ==>
http://www.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?