title: Initialization of vector in a constructor - C++
body: <p>I'm struggling with the constructor of one of my classes do to a member
  that is not initialized properly.</p>
  
  <p>I have a class "Settings" that handles the setting I use for my simulations
  and a class Simulations that performs the simulation steps.</p>
  
  <p>What I can't understand is why this code doesn't work as expected:</p>
  
  <pre><code>      class Settings{ 
           public: 
             int n ; // a number I need to create properly a vector in my class simulation
             // ... rest of the code constructors etc to read values from files.
             // everything works fine and the values are assigned properly
         }
  
         class Simulation{
            public:
            std::vector&lt;int&gt; v ;
            Settings *SP;
  
            Simulation(Settings *);
          }
  
          Simulation::Simulation(Settings *pS) 
             :SP(pS), v(std::vector&lt;int&gt;(SP-&gt;n,0)) {}    // the constructor doesn't work,
      // v is initialized but it is not created as a vector of size n, but 0.
  </code></pre>
  
  <p>I think there is a problem in the way I use the constructor but I can't understand why.</p>
  
  <p>By the way defining v inside the curly brackets works fine, I'm just curious to know why
  defining it the proper way doesn't work as expected!</p>
  
  <p>Thanks a lot for the help!</p>