In article <1129044046.615375.248530@g47g2000cwa.googlegroups .com>,
Kristo <kristo605@gmail.com> wrote:[color=blue]
>Ook wrote:[color=green]
>> Is there any kind of naming convention for accessor and modifiers? What I've
>> been doing is something like this:[/color]
>
>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.
>[color=green]
>> // accessor
>> int getSize();
>>
>> // Modifier
>> void setSize( int newsize);[/color]
>
>Sure, a lot of people name accessor/modifier functions this way.
>[color=green]
>> private:
>> int _size;[/color]
>
>Now *that* isn't allowed. Leading underscores are reserved for the
>implementation. I suggest changing that to size_.[/color]
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?