For members, I use
//.......vv
SomeType m_XXX;
//.......^^
I'd love to use _
as a prefix for member functions, but names starting with _
or __
are reserved and should not be used.
My idea is, that when I have:
SomeClass myObject;
myObject.[XXX]
when the user (of the lib) write the dot (.
), to see all functions (one after another) that are only public
.
Is there a common naming convention for this?
I know, that I can use pImpl
or inheritance, with interface and implementation classes
The most common practice is to name member functions without any common prefix or suffix. Personally, I see no benefit in differentiating them, and if your motivation relates to "write the dot (.), to see all functions" then it sounds like you should configure or change your editor, rather than change your programming style to suit it.
A good convention is the trailing underscore, like_this_
. Leading underscore is the Python way, however, in C++ all identifiers starting with underscore are reserved for the implementation.
Another option is to always prefix member access with this
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With