title: How to create a mock class with operator[]?
body: <p>I am having a class with <code>operator[]</code>, like this :</p>
  
  <pre><code>class Base
  {
    public:
      virtual ~Base(){}
      virtual const int &amp; operator[]( const unsigned int index ) const = 0;
  };
  </code></pre>
  
  <p>How can I create a mock class using google mock framework for this method?</p>
  
  <p>I tried this :  </p>
  
  <pre><code>class MockBase : public Base
  {
  public:
    MOCK_CONST_METHOD1( operator[],
                        const int&amp; ( const unsigned int )
                        );
  };
  </code></pre>
  
  <p>but that produces next errors :</p>
  
  <pre><code>error: pasting "]" and "_" does not give a valid preprocessing token
  error: pasting "]" and "_" does not give a valid preprocessing token
  error: pasting "]" and "_" does not give a valid preprocessing token
  error: pasting "]" and "_" does not give a valid preprocessing token
  </code></pre>