title: C2556: overloaded function differs only by return type
body: <p>I am reading Effective C++ which tells me that 'member functions differing only by their constness can be overloaded'.  </p>
  
  <p>The book example is:</p>
  
  <pre><code>class TextBlock {
  public:
     const char&amp; operator[](std::size_t position) const;
     char&amp; operator[](std::size_t position);
  
  private:
     std::string text;
  }
  </code></pre>
  
  <p>My example below, uses a stored pointer.</p>
  
  <pre><code>class A  {
  public:
     A(int* val) : val_(val) {}
  
     int* get_message() { return val_; }
  
     const int* get_message() { return val_; } const;
  
  private:
     int* val_;
  };
  </code></pre>
  
  <p>I get:</p>
  
  <blockquote>
    <p>error C2556: 'const int *A::get_message(void)' : overloaded function differs only by return type from 'int *A::get_message(void)'</p>
  </blockquote>
  
  <p>What is the difference?  Is there any way I can fix the class so I have a const and non-const version of get_message?</p>