title: Defining a constructor of a class in C++
body: <p>I am currently going through Bjarne Stroustrup's <strong>"The C++ Programming Language (4th Edition)"</strong> and am trying to understand whether is the following <em>a syntax error</em> or <em>was it the way I compiled it</em>.</p>
  
  <p>According to the following code snippet (extracted from the book), my constructor should look like this:</p>
  
  <pre><code>class Vector {
  public:
      Vector(int s): elem{new double[s]}, sz{s} {}   // Construct a Vector
      ...
  private:
      double* elem; // Pointer to the elements
      int sz;       // The number of elements
  };
  </code></pre>
  
  <p>But, I am unable to compile it unless I change the following as per the suggestion of the error message:</p>
  
  <pre><code>Vector(int s): elem(new double[s]), sz(s) {}
  </code></pre>
  
  <p>Note: I compiled my C++ codes using the following command through the Mac Terminal:</p>
  
  <pre><code>g++ -ansi -pedantic -Wall Test.cpp -o Test.o
  </code></pre>
  
  <p>Thank you in advance.</p>