title: why are more destroyed objects than created
body: <p>am new to c++ and and trying to learn the cost of copying values or passing references, in my example I found though a segment of code that is for me hard to understand:</p>
  
  <p>consider this example:</p>
  
  <pre><code>struct Foo {
  
      Foo(int x) :
              internVal { x } {
          std::cout &lt;&lt; "Con: " &lt;&lt; std::endl;
      }
      ~Foo() {
          std::cout &lt;&lt; "Des: " &lt;&lt; std::endl;
      }
      int getVal() const {
          return internVal;
  }
  private:
      int internVal { 0 };
  };
  </code></pre>
  
  <p>now when I do:</p>
  
  <pre><code>int main(int argc, char **argv) {
  
      {
          Foo a { 111 };
          Foo b { 6555 };
          Foo c { -444 };
          std::cout &lt;&lt; " Foos created..." &lt;&lt; std::endl;
          std::vector&lt;Foo&gt; vector_Test { };
          vector_Test.push_back(a);
          vector_Test.push_back(b);
          vector_Test.push_back(c);
          std::cout &lt;&lt; " Foos added..." &lt;&lt; std::endl;
  
          for (const auto&amp; d : vector_Test) {
              std::cout &lt;&lt; "-----" &lt;&lt; d.getVal() &lt;&lt; "-----" &lt;&lt; std::endl;
          }
          std::cout &lt;&lt; " Foos printed..." &lt;&lt; std::endl;
      }
      std::cout &lt;&lt; " Foos out of scope..." &lt;&lt; std::endl;
      std::cout &lt;&lt; "end!" &lt;&lt; std::endl;
  
      //
      return 0;
  }
  </code></pre>
  
  <p>I see the following output:</p>
  
  <pre><code>Con: 
  Con: 
  Con: 
   Foos created...
  Des: 
  Des: 
  Des: 
   Foos added...
  -----111-----
  -----6555-----
  ------444-----
   Foos printed...
  Des: 
  Des: 
  Des: 
  Des: 
  Des: 
  Des: 
   Foos out of scope...
  end!
  </code></pre>
  
  <p>so my question  why are more objects destroyed as created?</p>
  
  <p>I would expect an even number... if I create directly/ indirectly 3 objects then destroy 3 objects</p>
  
  <p>Do I habe a memory leak some where?</p>
  
  <p>thanks</p>
  
  <p>Ps: my compiler is MinWG </p>