title: my own smart pointer template compilation error
body: <p>I am having following simple program from scott meyers book. I am compiling using Visual studio 2009. </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;algorithm&gt;
  
  using namespace std;
  
  
  class Top {  };
  
  class Middle: public Top {  };
  
  class Bottom: public Middle {  };
  
  
  
  template&lt;typename T&gt;
  
  class SmartPtr {
  
  public:
  
      template&lt;typename U&gt;
  
      SmartPtr(const SmartPtr&lt;U&gt;&amp; other) : heldPtr(other.get()) { }
  
      T* get() const { return heldPtr; }
  
  
  private:
  
      // built-in pointer held
  
      T *heldPtr;
  
  };
  
  
  
  int main()
  {
      SmartPtr&lt;Top&gt; pt1 = SmartPtr&lt;Middle&gt;(new Middle); //  SmartPtr&lt;Top&gt;
  }
  </code></pre>
  
  <p>During compilation i am getting following error</p>
  
  <pre><code>1&gt;d:\technical\c++study\addressconv.cpp(36) : error C2440: '&lt;function-style-cast&gt;' : cannot convert from 'Middle *' to 'SmartPtr&lt;T&gt;'
  1&gt;        with
  1&gt;        [
  1&gt;            T=Middle
  1&gt;        ]
  1&gt;        No constructor could take the source type, or constructor overload resolution was ambiguous
  1&gt;d:\technical\c++study\readparsing\readparsing\addressconv.cpp(36) : error C2512: 'SmartPtr&lt;T&gt;' : no appropriate default constructor available
  1&gt;        with
  1&gt;        [
  1&gt;            T=Top
  1&gt;        ]
  </code></pre>
  
  <p>Kindly request to help in resolving problem. What is root cause of problem?</p>
  
  <p>Thanks!</p>