Victor Bazarov wrote:
> Ares Lagae wrote:
>> When adopting the coding style of the standard C++ library, you often run
>> into naming problems because class names are lower case, and member
>> functions do not have get/set prefixes.
>
> No, I don't run into issues like that, why do you think I do?
Suppose you have a class color, and a class pen. Adopting the coding style
of the standard C++ library, pen would have a member function "color
pen::color()", and you would have a problem. You can solve this problem
like the C++ standard library does: rename the member function, and
introduce a less logical name. I hope you recognize this situation is
identical to the the "locale ios_base::getloc()" example.
When using aggregation, sometimes the role name can be used. For example,
when you have a class person and a class account, you would introduce a
member function "person account::holder()" instead of "person
account:

erson". However, there are many cases in which a role name is not
obvious (like in the pen/color example). Then you run into the problem I
describe.
I explicitely mentioned I did not want to discuss coding style, or wether
the names in the standard C++ library are logical or not...
>
> As to your example
>
> class foo {};
>
> class bar {
> public:
> foo foo();
> };
>
> It's clear nonsense because class bar should simply have the operator foo
> instead of oddly named function.
Is it? Again, suppose you have a class color, and a class pen. Then you say
the class pen should have an operator color instead of a member function
color ? Just because the names match ? If this is the case, I would rather
not have you coding in my company.
Best regards,
Ares Lagae