title: About copy control in C++
body: <p>I defined a class named Student.</p>
  
  <pre><code>// Student.h
  #pragma once
  #include &lt;iostream&gt;
  using namespace std;
  
  class Student {
  public:
      Student();
      Student(const Student &amp;s);
      Student(int ii);
      Student&amp; operator=(const Student &amp;s);
      ~Student();
  private:
      int i;
  };
  
  // Student.cpp
  #include "Student.h"
  
  Student::Student(): i(0)
  {
      cout &lt;&lt; "ctor" &lt;&lt; endl;
  }
  
  Student::Student(const Student &amp;s)
  {
      i = s.i;
      cout &lt;&lt; "copy constructor" &lt;&lt; endl;
  }
  
  Student::Student(int ii): i(ii)
  {
      cout &lt;&lt; "Student(int ii)" &lt;&lt;  endl;
  }
  
  Student&amp; Student::operator=(const Student &amp;s)
  {
      cout &lt;&lt; "assignment operator" &lt;&lt; endl;
      i = s.i;
      return *this;
  }
  
  Student::~Student()
  {
  }
  
  // main.cpp
  #include &lt;vector&gt;
  #include "Student.h"
  
  int main()
  {
      vector&lt;Student&gt; s(5);
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>I ran this program on Visual Studio 2015.<br>
  Output result:  </p>
  
  <pre><code>ctor  
  ctor  
  ctor  
  ctor  
  ctor  
  </code></pre>
  
  <p>But I expect the result is:  </p>
  
  <pre><code>ctor  
  copy constructor  
  copy constructor  
  copy constructor  
  copy constructor  
  copy constructor  
  </code></pre>
  
  <p>Am I wrong?  Additionally, I wrote:</p>
  
  <pre><code>Student s1;
  Student s2 = s1;
  </code></pre>
  
  <p>Output result:  </p>
  
  <pre><code>ctor  
  copy constructor  
  </code></pre>
  
  <p>instead of:  </p>
  
  <pre><code>ctor  
  copy constructor  
  copy constructor  
  </code></pre>
  
  <p>as C++ primer(the fourth edition) said in Chapter 13.</p>
  
  <p>The third one, when I wrote:</p>
  
  <pre><code>Student s = 3;
  </code></pre>
  
  <p>Output result:</p>
  
  <pre><code>Student(int ii)
  </code></pre>
  
  <p>I think this one should be: </p>
  
  <pre><code>Student(int ii)  
  copy constructor  
  </code></pre>