title: why shared_ptr can access with ingoring the "protected access right"
body: <p>I made some testing with shared_ptr,and i can't think out the matter below.I just started to learn the boost library. Is there anybody can tell me the reason?</p>
  
  <pre><code>#include &lt;boost\shared_ptr.hpp&gt;
  #include &lt;iostream&gt;
  
  class A 
  {
  public:  
      virtual void sing()
      {
          std::cout&lt;&lt;"A";
      }
  protected:  virtual ~A() {};
  
  };
  
  class B : public A 
  {
  public:  
      virtual void sing() 
      {   
          std::cout &lt;&lt; "B"; 
      }
      virtual ~B() {};
  };
  
  
  int foo()
  {   
      boost::shared_ptr&lt;A&gt; pa(new B());
      pa-&gt;sing();
  
      delete static_cast&lt;B*&gt;(pa.get());
  
      delete pa.get(); //this line has a problem error C2248: “A::~A”: can't access protected memmber(declared in class“A")   
      return 0;
  }
  
  int main()
  {
      foo();
      return 0;
  }
  </code></pre>
  
  <p>but it can be compiled when that line is commented out. Surely it doesn't mean that the shared_ptr will delete the pointer internally maintained out of the main function, just like what i did. Is there any difference between the pointer returned by <code>pa.get()</code> and the pointer internally maintained?</p>