title: C++ initialization list in constructor
body: <p>I'm trying to initialize an instance of a class called &quot;Winery&quot; using an initialization list in the constructor for another class called &quot;List.&quot; The problem is that when I hand the Winery constructor a winery to copy, it fails to copy the information.</p>
  <p>This the header file for the Winery class:</p>
  <pre><code>class Winery
  {
  public:
  
      Winery(const char * const name,
             const char * const location,
             const int acres,
             const int rating);
      virtual ~Winery(void);
  
      const char * const getName() const { return name; }
      const char * const getLocation() const { return location; }
      const int getAcres() const { return acres; }
      const int getRating() const { return rating; }
  
  private:
      char *name;
      char *location;
      int  acres;
      int  rating;
  };
  </code></pre>
  <p>Here is the relevant part of the header file for my List class:</p>
  <pre><code>struct Node
  {
      Node(const Winery&amp; winery);
      Winery item;
      Node *nextByName;
      Node *nextByRating;
  };
  </code></pre>
  <p>Here is the constructor in my List class:</p>
  <pre><code>List::Node::Node(const Winery&amp; winery) :
      item(winery.getName(),
           winery.getLocation(),
           winery.getAcres(),
           winery.getRating()),
      nextByName(nullptr),
      nextByRating(nullptr)
  {
  }
  </code></pre>
  <p>From what I see, it looks like I'm doing everything I need to be doing. The data members of the winery that I'm passing to the constructor are private, so I'm trying to get them via the functions that get information. They're in the proper order and everything.</p>
  <p>The pointers work just fine after I initialize them, but the information isn't there, so I really don't know what to do here. If you're wondering, this is for an assignment and we <em>have</em> to use initialization lists (I've tried it without them and that doesn't work either so I really don't know what to do).</p>
  <p>Here is my Winery constructor:</p>
  <pre><code>Winery::Winery(const char * const name,
                 const char * const location,
                 const int acres,
                 const int rating) :
      acres(acres),
      rating(rating)
  {
      char *newName = new char[sizeof(name) + 1];
      char *newLocation = new char[sizeof(location) + 1];
  }
  </code></pre>