title: Constructor Initializer List vs Constructor Body
body: <p>Let's say <strong>someString</strong> initialization is a tad complicated, hence we write a simple member function <strong>stringInitialization()</strong> with which to initialize <strong>someString</strong> in the body of the constructor:</p>
  <pre><code>class DemoL {
  private:
  
      int someNumber;
      std::string someString;
  
      void stringInitialization() {
          if (someNumber == 1) {
              someString = &quot;FIRSTSTRING&quot;;
          } else if (someNumber == 2) {
              someString = &quot;SECONDSTRING&quot;;
          } else {
              someString = &quot;&quot;;
          }
      }
  
  public:
      explicit DemoL(int rNumber) :
              someNumber(rNumber) {
          stringInitialization();
      }
  };
  </code></pre>
  <p>This way, I'd assume, <strong>someString</strong> will be default initialized before the body of the constructor and only after that will it be modified by calling <strong>stringInitialization()</strong>.</p>
  <p>So, let's modify the code a bit, so that we initialize <strong>someString</strong> in the constructor initializer list:</p>
  <pre><code>class DemoL {
  private:
  
      int someNumber;
      std::string someString;
  
      std::string stringInitialization() const {
          if (someNumber == 1) {
              return &quot;FIRSTSTRING&quot;;
          } else if (someNumber == 2) {
              return &quot;SECONDSTRING&quot;;
          } else {
              return &quot;&quot;;
          }
      }
  
  public:
      explicit DemoL(int rNumber) :
              someNumber(rNumber),
              someString(stringInitialization()) {}
  };
  </code></pre>
  <p>Would you be so kind as to tell me whether the second variant is more efficient and correct?</p>