title: C++ const method returning non const pointer
body: <p>As an exercise in learning C++, I've created the following wrapper class which encapsulated the creation/destruction of a simple character buffer:</p>
  <pre><code>class BufferClass {
    private:
      char *mBufferPtr;
      
    public:
      BufferClass(int pSize)
        : mBufferPtr(new char[pSize]) {}
      
      virtual ~BufferClass() {
        delete[] mBufferPtr;
      }
      
      operator char*() {
        return mBufferPtr;
      }
      
      operator const char*() const {
        return mBufferPtr;
      }
  };
  </code></pre>
  <p>If there was a circumstance where I wanted to create a const instance of this class (i.e. I have no intention of modifying the object once constructed), but had to use it in conjuction with a C API which only accepts non-const char* pointers (even thought it doesn't mutate the data), what's the general consensus on allowing the following:</p>
  <pre><code>operator char*() const {
    return mBufferPtr;
  }
  </code></pre>
  <p>I realise I could just create a non-const instance of the Buffer class, but I'd be interested in comments regarding the validity of this approach.</p>