title: "member function already defined or declared" - What does that mean?
body: <p>I am writing a program, which should list some tasks, order them by date and so on.</p>
  
  <p>The last thing I did was, to add the "sort by date" functionality. Before that everything worked fine. If I run my code now, I get the following error message (I get this message 3 times)</p>
  
  <pre class="lang-none prettyprint-override"><code>member function already defined or declared
  </code></pre>
  
  <p>I don't understand, what is wrong. The code that triggers the error looks like this:</p>
  
  <pre><code>static bool compareDates(entry e1, entry e2) { 
      string s1 = e1.date;
      string s2 = e2.date;
  
      int day_1 = atoi(s1.substr(0, 2).c_str());
      int month_1 = atoi(s1.substr(3, 2).c_str()); // dd.mm.yyyy
      int year_1 = atoi(s1.substr(6, 4).c_str());
  
      int day_2 = atoi(s2.substr(0, 2).c_str());
      int month_2 = atoi(s2.substr(3, 2).c_str());
      int year_2 = atoi(s2.substr(6, 4).c_str());
  
      if (year_1 &gt; year_2) return true;
      else if (year_1 &lt; year_2) return false;
  
      if (month_1 &gt; month_2) return true;
      else if (month_1 &lt; month_2) return false;
  
      if (day_1 &gt; day_2) return true;
      else if (day_1 &lt; day_2) return false;
  
      return true;
  }
  
  // ... some code in between ...
  
  private: void sortList() { // in the class
      sort(john_lines.begin(), john_lines.end(), compareDates);
      sort(tomas_lines.begin(), tomas_lines.end(), compareDates);
      sort(bernd_lines.begin(), bernd_lines.end(), compareDates);
      sort(peter_lines.begin(), peter_lines.end(), compareDates);
  }
  </code></pre>
  
  <p>I tried to run this code without the rest, and it worked. Does somebody know what is wrong with my application? Here is the error message I receive:</p>
  
  <pre class="lang-none prettyprint-override"><code>Error 1 error C2535: 'void V2::MainWindow::sortList(void)' : member function already defined or declared
  &lt;path&gt;\MainWindow.h 422 1 V2
  
  Error 14 error C2535: 'void V2::MainWindow::sortList(void)' : member function already defined or declared
  &lt;path&gt;\MainWindow.h 422 1 V2
  
  Error 28 error C2535: 'void V2::MainWindow::sortList(void)' : member function already defined or declared
  &lt;path&gt;\MainWindow.h 422 1 V2
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;vector&gt;
  #include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  #include &lt;exception&gt;
  #include &lt;algorithm&gt;
  #include &lt;stdio.h&gt;
  
  using namespace std;
  
  struct entry {
      string text;
      string date;
      bool finished;
  };
  
  vector&lt; entry &gt; john_lines;
  
  bool compareDates(entry e1, entry e2) {
      string s1 = e1.date;
      string s2 = e2.date;
  
      int day_1 = atoi(s1.substr(0, 2).c_str());
      int month_1 = atoi(s1.substr(3, 2).c_str()); // dd.mm.yyyy
      int year_1 = atoi(s1.substr(6, 4).c_str());
  
      int day_2 = atoi(s2.substr(0, 2).c_str());
      int month_2 = atoi(s2.substr(3, 2).c_str());
      int year_2 = atoi(s2.substr(6, 4).c_str());
  
      if (year_1 &gt; year_2) return true;
      else if (year_1 &lt; year_2) return false;
  
      if (month_1 &gt; month_2) return true;
      else if (month_1 &lt; month_2) return false;
  
      if (day_1 &gt; day_2) return true;
      else if (day_1 &lt; day_2) return false;
  
      return true;
  }
  
  int main() {    
      entry e;
  
      e = { "clean the window", "12.08.2016", true };
      john_lines.push_back(e);
      e = { "tidy the room", "14.06.2012", false };
      john_lines.push_back(e);
      e = { "sort the papers", "16.08.2016", false };
      john_lines.push_back(e);
      e = { "writing the code for this application", "19.08.2018", false };
      john_lines.push_back(e);
      e = { "test period of this applicaition", "30.11.2020", false };
      john_lines.push_back(e);
  
      cout &lt;&lt; "-------------------------------------------------------------------------------" &lt;&lt; endl;
      cout &lt;&lt; "- before:                                                                     -" &lt;&lt; endl;
      cout &lt;&lt; "-------------------------------------------------------------------------------" &lt;&lt; endl;
  
      for(int i=0; i&lt;john_lines.size(); i++) {
          e = john_lines.at(i);
          string finished = (e.finished) ? "(  done  ) " : "(not done) ";
          cout &lt;&lt; finished &lt;&lt; e.date &lt;&lt; " - " &lt;&lt; e.text &lt;&lt; endl;
      }
      cout &lt;&lt; endl &lt;&lt; endl;
  
      sort(john_lines.begin(), john_lines.end(), compareDates);
  
      cout &lt;&lt; "-------------------------------------------------------------------------------" &lt;&lt; endl;
      cout &lt;&lt; "- after:                                                                      -" &lt;&lt; endl;
      cout &lt;&lt; "-------------------------------------------------------------------------------" &lt;&lt; endl;
  
      for(int i=0; i&lt;john_lines.size(); i++) {
          e = john_lines.at(i);
          string finished = (e.finished) ? "(  done  ) " : "(not done) ";
          cout &lt;&lt; finished &lt;&lt; e.date &lt;&lt; " - " &lt;&lt; e.text &lt;&lt; endl;
      }
  }
  </code></pre>