title: Enum & class member function with the same name
body: <p>In the particular coding standard being enforced at my workplace, accessor methods in a class follow a specific naming convention. For any given member variable, the getter is the same name, and the setter is prefixed with <code>Set</code>. See example below.</p>
  
  <pre><code>class Foo
  {
  public:
      int Number() const { return m_number; }
      void SetNumber(int number) { m_number = number; }
  
  private:
      int m_number;
  };
  </code></pre>
  
  <p>This becomes quirky when I have an enum with the same name:</p>
  
  <pre><code>enum class Number
  {
      One, Two, Three
  };
  
  class Foo
  {
  public:
      Number Number() const { return m_number; }
      void SetNumber(Number number) { m_number = number; }
  
  private:
      Number m_number;
  };
  </code></pre>
  
  <p>The above example will not compile because in some places, the compiler can't determine if I'm referring to the enum name or the function name. So to fix this without violating the coding standard, I would have to use <code>::</code> in places of ambiguity and I'm actually referring to the enum:</p>
  
  <pre><code>enum class Number
  {
      One, Two, Three
  };
  
  class Foo
  {
  public:
      ::Number Number() const { return m_number; }
      void SetNumber(::Number number) { m_number = number; }
  
      void DoStuffWithNumber()
      {
          if (m_number == ::Number::One)
          {
              // Do stuff
          }
      }
  
  private:
      Number m_number;
  };
  </code></pre>
  
  <p>This is a little confusing for readers of the code, but also a bit annoying to have to fully qualify the enumeration name in certain contexts. It's not straightforward all the time.</p>
  
  <p>What's a more reasonable workaround here? Obviously I could do something like rename the accessor to <code>GetNumber()</code>, but I'm curious to see what other solutions people can come up with.</p>