title: Converting C++ linked stack into smart pointers
body: <p>I have a question on converting the following code into smart pointers, in particular in terms of shared pointers. Node.cpp is an implementation file of the class template <code>Node&lt;T&gt;</code>, wherein its constructor is defined as below.</p>
  <p>Node.cpp</p>
  <pre><code>...
  template &lt;typename T&gt;
  Node&lt;T&gt;::Node(const T&amp; anItem, std::shared_ptr&lt;Node&lt;T&gt;&gt; nextNodePtr)
      : item(anItem), next(nextNodePtr) { }
  
  ...
  </code></pre>
  <p>LinkedStack.cpp</p>
  <pre><code>...
  template &lt;typename T&gt;
  bool LinkedStack&lt;T&gt;::push(const T&amp; newItem) {
  
     topPtr = new Node&lt;T&gt;(newItem, topPtr);
  
     return true;
  }
  ...
  </code></pre>
  <p><strong>LinkedStack.cpp (in terms of shared pointers, my attempt)</strong></p>
  <pre><code>...
  template &lt;typename T&gt;
  bool LinkedStack&lt;T&gt;::push(const T&amp; newItem) {
  
     std::shared_ptr&lt;Node&lt;T&gt;&gt; topPtr
         = std::make_shared&lt;Node&lt;T&gt;&gt;(Node&lt;T&gt;(newItem, topPtr));
     return true;
  }
  ...
  </code></pre>
  <p>Is this a correct way to transform LinkedStack.cpp into the form that uses shared pointers?</p>