title: C++: vector.erase instance of a class with const int gives "attempting to reference a deleted function" error C2280
body: <p>C++: vector.erase instance of a class with const int gives "attempting to reference a deleted function" error C2280</p>
  
  <p>Class B has a const int attribute <code>const_int</code>. If I make a vector of B instances and then delete an element from that vector - I get the following error:</p>
  
  <pre><code>Error   C2280   'B &amp;B::operator =(const B &amp;)': attempting to reference a deleted function   VectorTest  c:\program files (x86)\microsoft visual studio\2017\prof\vc\tools\msvc\14.10.25017\include\xutility 2534    
  </code></pre>
  
  <p>If I remove the <code>const</code> keyword - the error disappears.
  How do I fix it while keeping my attribute <code>const_int</code> constant?
  Why does this error appear, is vector.erase() trying to call some function from class B?
  Thank you!</p>
  
  <p>B.h</p>
  
  <pre><code>#pragma once
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  class B
  {
  private:
      const int const_int;
  public:
      B(int const_int_input);
      ~B();
  };
  </code></pre>
  
  <p>B.cpp</p>
  
  <pre><code>#include "B.h"
  
  B::B(int const_int_input) : const_int(const_int_input)
  {
  }
  
  
  B::~B()
  {
  }
  </code></pre>
  
  <p>Source.cpp</p>
  
  <pre><code>#include "B.h"
  
  int main() {
      vector&lt;B&gt; test;
      test.push_back(B(1));
      test.erase(test.begin());
      return 0;
  }
  </code></pre>