title: sort and binary_search on array of struct
body: <p>here's my code</p>
  
  <pre><code>typedef struct Data{
      int date;
      string currency;
      string exchange;
      float low;
      float high;
      long long int daily_cap;
  }Data;
  
  bool comp2(const Data *data1, const Data *data2){
          return (data1-&gt;date &lt; data2-&gt;date);
  }
  
  bool comp1(Data *data1, Data *data2){
      if (data1-&gt;date != data2-&gt;date)
          return (data1-&gt;date &lt; data2-&gt;date);
      if (data1-&gt;currency != data2-&gt;currency)
          return (data1-&gt;currency &lt; data2-&gt;currency);
      else
          return (data1-&gt;exchange &lt; data2-&gt;exchange);
  }
  
  int main()
  {
      ifstream infile("test.txt");
      Data tmp;
      vector&lt;Data*&gt; P_data;
  
          while (infile){
          Data *tmp = new Data();
          infile &gt;&gt; tmp-&gt;date;
          infile &gt;&gt; tmp-&gt;currency;
          infile &gt;&gt; tmp-&gt;exchange;
          infile &gt;&gt; tmp-&gt;low;
          infile &gt;&gt; tmp-&gt;high;
          infile &gt;&gt; tmp-&gt;daily_cap;
          P_data.push_back(tmp);
      }
  
      sort(P_data.begin(), P_data.end(), comp1);
  
  //  bool yes = binary_search(P_data.begin()+1, P_data.end(), 20140212, comp2);
  
      int c = 0;
      for (int i = 0; i&lt;= 20; ++i){
          cout &lt;&lt; P_data[i]-&gt;date &lt;&lt; " " &lt;&lt; P_data[i]-&gt;exchange &lt;&lt; " " &lt;&lt; c &lt;&lt; endl;
          c++;
      }
  
  }
  </code></pre>
  
  <p>the first question is that why after sorting,</p>
  
  <p>the first line will be </p>
  
  <pre><code>-842150451  0
  </code></pre>
  
  <p>and the second line start sorting</p>
  
  <pre><code>20130101 Wii 0 ....
  </code></pre>
  
  <p>and the second question is binary_search</p>
  
  <p>Is there anything wrong in my code ?</p>
  
  <p>the error message show that </p>
  
  <p>bool(const Data*, const Data*)  can't convert arg1  'const int'  to  'const Data*'</p>