title: Create a function that removes duplicates in a vector
body: <p>I created a function create() that generate 10 random numbers in a vector. And I am trying to create a function that removes duplicates. When I print the vector within the function remove_dup(), it works. But when I print it in the main function, it doesn't work. Please help. The other examples on here are not in a function.</p>
  <pre><code>#include &lt;ctime&gt;
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;cstdlib&gt;
  #include &lt;bits/stdc++.h&gt;
  
  using namespace std;
  
  
  vector &lt;int&gt; listt;
  vector &lt;int&gt; list2;
  int number=0;
  int create() {
  
      srand((unsigned) time(0));
    for (int i = 0; i &lt; 10; i++) {
      number = (rand() % 20) + 1;
      listt.push_back(number);
    }
  return 0;
  }
  void print(vector &lt;int&gt; a) {
     cout &lt;&lt; &quot;The vector elements are : &quot;;
  
     for(int i=0; i &lt; a.size(); i++)
          cout &lt;&lt; a[i] &lt;&lt; ' ';
  }
  
  
  vector &lt;int&gt; remove_dup(vector &lt;int&gt; listt) {
  sort(listt.begin(), listt.end());
  for(int i=0; i &lt; listt.size(); i++){
          if (listt[i-1]==listt[i]){
              listt.erase(listt.begin()+i);
              i=0;
  
          }
  }
  return listt;
  
  }
  
  using namespace std;
  int main() {
  create();
    print(listt);
    cout&lt;&lt;endl;
    remove_dup(listt);
    print(listt);
  
  
  }
  </code></pre>