C++ Initializing a vector inside a struct definition
<p>I'm reading through Programming Principles and Practice C++, and came across the following piece of code which I don't think was well explained</p>

<pre><code>struct Day {
    vector&lt;double&gt; hour{vector&lt;double&gt;(24,-777) };
};
</code></pre>

<p>What is happening here? I usually use this initializer when I need a vector of a certain length with default values:</p>

<pre><code>vector&lt;double&gt; hour(24, -777);
</code></pre>

<p>However, this way of initializing does not work inside the struct,</p>

<pre><code>struct Day {
    vector&lt;double&gt; hour(24, -777);
};
</code></pre>

<p>Results in a compile error </p>

<pre><code>Error (active)      expected a type specifier   HelloWorld  d:\Visual Studio 2015\HelloWorld\HelloWorld\HelloWorld.cpp  11  
Error (active)      expected a type specifier   HelloWorld  d:\Visual Studio 2015\HelloWorld\HelloWorld\HelloWorld.cpp  11  
Error   C2059   syntax error: 'constant'    HelloWorld  d:\visual studio 2015\helloworld\helloworld\helloworld.cpp  11  
</code></pre>

<p>Looking for an explanation behind the initializers.</p>

<p>I'm using MS Visual Studio 2015</p>