title: Why weak pointer is getting created with shared_ptr?
body: <p>I have written following simple code,</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt;
  
  struct Foo
  {
      Foo()      { std::cout &lt;&lt; "Foo::Foo\n";  }
      ~Foo()     { std::cout &lt;&lt; "Foo::~Foo\n"; }
      void bar() { std::cout &lt;&lt; "Foo::bar\n";  }
  };
  
  int main()
  {
      std::shared_ptr&lt;Foo&gt; p1(new Foo);//this line
  
      p1-&gt;bar();
  
      std::shared_ptr&lt;Foo&gt; p2(p1);
  }
  </code></pre>
  
  <p>And in watch window I got,</p>
  
  <pre><code>p2  std::__1::shared_ptr&lt;Foo&gt;   ptr = 0x100104350 strong=2 weak=1   
  p1  std::__1::shared_ptr&lt;Foo&gt;   ptr = 0x100104350 strong=2 weak=1   
  </code></pre>
  
  <p>Now, I can understand strong=2, but why weak = 1? </p>
  
  <p>Secondly, in code I changed code to,</p>
  
  <pre><code>std::shared_ptr&lt;Foo&gt; p1(std::move(new Foo));
  </code></pre>
  
  <p>Because, may be one weak pointer is because of nameless object. So I have moved it while creating p1, still I get same output in watch window.</p>
  
  <p>Please suggest which point I am missing?</p>