title: Overloading == operator causes discards qualifiers error
body: <p>I am making a complex number class using C++. And I want to overload the == operator.
  But I got this error:</p>
  
  <pre><code>In file included from Complex.cpp:1:0,
               from testComplex.cpp:2:
  Complex.h: In function ‘bool operator==(const Complex&amp;, const Complex&amp;)’:
  Complex.h:29:21: error: passing ‘const Complex’ as ‘this’ argument of ‘double Complex::real()’ discards qualifiers [-fpermissive]
       return (c1.real() == c2.real() &amp;&amp; c1.imag() == c2.imag());
  </code></pre>
  
  <p>Here is my class file:</p>
  
  <pre><code>#ifndef COMPLEX_H
  #define COMPLEX_H
  
  class Complex{
      public:
      Complex(void);
      Complex(double a, double b);
      Complex(double a);
      double real(){ 
          return a;
      }
  
      double imag(){
          return b;
      }
      private:
      double a;
      double b;
  };
  
  bool operator==(const Complex&amp; c1, const Complex&amp; c2){
      return (c1.real() == c2.real() &amp;&amp; c1.imag() == c2.imag());
  }
  #endif
  </code></pre>
  
  <p>How to fix it?</p>