title: How to simple assign vectors of different structs?
body: <p>So I have two different structs (a &amp; b) with same variables and an overloaded = operator in struct b to convert a to b.</p>
  
  <p>I want to be able to simple assign a vector of a to a vector b, but compiler gives me an error:</p>
  
  <pre><code>main.cpp|61|error C2679: binary '=' : no operator found which takes a right-hand operand of type 'std::vector&lt;_Ty&gt;' (or there is no acceptable conversion)|
  </code></pre>
  
  <p>I assumed that I already had the overloaded = operator and that it would simply iterate over vector a and use that = operator for each instance. How would I do this?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  struct a
  {
      int x, y;
      a() {}
      a(int _x, int _y)
      {
          x = _x;
          y = _y;
      }
  };
  
  struct b
  {
      int x, y;
      b(){}
      b(int _x, int _y)
      {
          x = _x;
          y = _y;
      }
  
      b&amp; operator=(const a&amp; _a)
      {
          x = _a.x;
          y = _a.y;
          return *this;
      }
  };
  
  int main()
  {
      a a_test(1,2);
  
      std::vector&lt;a&gt; a_vec;
      std::vector&lt;b&gt; b_vec;
  
      for(int i = 0; i &lt;10; i++)
      {
          a_vec.push_back(a_test);
      }
  
      /*
      for(int i = 0; i&lt;a_vec.size(); i++)
      {
          b_vec.push_back(a_vec[i]);
      }
      */
  
      b_vec = a_vec;
  
      return 0;
  }
  </code></pre>