title: No matching member function for call to 'erase' while erasing a value from vector
body: <p>I am trying to write this code but this is giving the error</p>
  <pre class="lang-cpp prettyprint-override"><code>No matching member function for call to 'erase'clang(ovl_no_viable_member_function_in_call)
  stl_vector.h(1317, 7): Candidate function not viable: no known conversion from 'int' to 'std::vector&lt;int, std::allocator&lt;int&gt; &gt;::const_iterator' (aka '__normal_iterator&lt;const int *, std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt;') for 1st argument
  stl_vector.h(1344, 7): Candidate function not viable: requires 2 arguments, but 1 was provided
  </code></pre>
  <p>Here is my Code</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  
  int sockMerchant(int n, vector&lt;int&gt; ar) {
      int pairCount=0;
      for(int i=0;i&lt;ar.size();i++)
      {
          for(int j=i+1;j&lt;ar.size();j++)
          {
              if(ar[i]==ar[j])
              pairCount++;
              ar.erase(j);
          }
      }
      return pairCount;
  }
  
  int main()
  {
      int n;
      cin&gt;&gt;n;
      vector &lt;int&gt; arr;
      for(int i=0;i&lt;n;i++)
      {
          int e=0;
          cin&gt;&gt;e;
          arr.push_back(e);
      }
      sockMerchant(n, arr);
  }
  </code></pre>
  <p>Also if you can, please tell me why am I getting this error as I followed the same approach of erase function as it was done in gfg.</p>