title: C++ const "and the object has type qualifiers that are not compatible with the member
body: <p>I'm new to C++ programming and in my OPP class we were requested to create a phone book.</p>
  
  <p>Now, in the lecture the Professor said something about that if you want to make sure that your variable that is being injected to a method doesn't get changed you must put const on it.</p>
  
  <p>here is my code so far.</p>
  
  <pre><code>private:
   static int phoneCount;
   char* name;
   char* family;
   int phone;
   Phone* nextPhone;
  
  public:
      int compare(const Phone&amp;other) const;
      const char* getFamily();
      const char* getName();
  </code></pre>
  
  <p>and in Phone.cpp</p>
  
  <pre><code>int Phone::compare(const Phone &amp; other) const
  {
   int result = 0;
   result = strcmp(this-&gt;family, other.getFamily());
   if (result == 0) {
      result = strcmp(this-&gt;name, other.getName);
   }
   return 0;
  }
  </code></pre>
  
  <p>I keep getting "the object has type qualifiers that are not compatible with the member"
   when I try to call to strcmp inside my compare function.
  I know that I can just remove the const in the function declaration and it will go away, but I still doesn't understand why it's showing in the first place.</p>
  
  <p>Help would be greatly appreciated. </p>