Currently I use same convention for class names and method names. They have a leading capital letter without prefix. And I don’t use “Get” prefix to get an attribute. However, I meet a name conflict problem in the following code
class Material
{};
class Background
{
public:
Material* Material() const {return m_material;} // Name conflict
void SetMaterial(Material* material) {m_material = material;}
private:
Material* m_material;
};
What is the easiest way to solve the problem but keeping or with minimum modification of my conventions? Thanks a lot!
The easiest way might be to slightly modify the convention, such as start method names with lowercase.
BTW, I like that you are not using the word “get” in the accessor method. In the same spirit, you may drop the word “set” in the mutator method (here,
SetMaterial()). The signature would be sufficient to distinguish the accessor and mutator.If you like them, you would reach at: