title: Initialize struct with deep copy of object passed by reference
body: <p>I am working on an assignment for a class, and have a linked list that holds an object in each node. The nodes are implemented as structs. I am having trouble initializing the object because it seems I need to make a deep copy, but am not. For the life of me, I can't figure out how to make it a deep copy. Every time the original object is deleted, the name and location get deleted as well.</p>
  
  <p>I know that other students in the same class have asked similar questions, such as <a href="https://stackoverflow.com/questions/26310837/how-do-i-make-a-deep-copy-in-a-constructors-initialization-list-c">this</a>, but my code is the same and I still end up with problems.</p>
  
  <p>The nodes are constructed like so:</p>
  
  <pre><code>List::Node::Node(const Winery&amp; winery) :
      item(winery),
      nextByName(nullptr),
      nextByRating(nullptr)
  {
  }
  </code></pre>
  
  <p>The definition of the Node struct:</p>
  
  <pre><code>struct Node
      {
          Node(const Winery&amp; winery);     // constructor
          Winery item;                    // an instance of winery
                                          // (NOT a pointer to an instance)
          Node *nextByName;               // next node in the name thread
          Node *nextByRating;             // next node in the rating thread
      };
  </code></pre>
  
  <p>The winery class is constructed like so:</p>
  
  <pre><code>Winery::Winery(const char * const name, const char * const location, const int acres, const int rating) :
      name(new char[strlen(name) + 1]),
      location(new char[strlen(location) + 1]),
      acres(acres),
      rating(rating)
  {
      strcpy(this-&gt;name, name);
      strcpy(this-&gt;location, location);
  }
  </code></pre>
  
  <p>I am fairly certain this is making a deep copy, so the problem is in the construction of the node, not the winery.</p>