title: C++ Class Initialization List example
body: <p>I am going through Chapter 17 in the new Stroustrup book and I am confused by initializing a class with an initialization list.</p>
  
  <p>Example:</p>
  
  <p>in .hpp:</p>
  
  <pre><code>class A
  {
      public:
          A() : _plantName(std::string s), _growTimeMinutes(int 1);
          virtual ~A();
  
      private:
          std::string _plantName;
          int _growTimeMinutes;
  };
  </code></pre>
  
  <p>in .cpp:</p>
  
  <pre><code>A::A() : _plantName(std::string s), _growTimeMinutes(int i)
  {
  
  }
  </code></pre>
  
  <p>or is it in .cpp:</p>
  
  <pre><code>A::A(std::string s, int i) : _plantName(std::string s), _growTimeMinutes(int i)
  {
  
  }
  </code></pre>
  
  <p>and calling that:</p>
  
  <pre><code>A a {"Carrot", 10};
  </code></pre>
  
  <p>I learned c++ back in 1998 and have only programmed in it off and on over the years until recently. How long ago did this stuff change? I know I could still do that the older way but I really want to learn new!</p>