question

Apr 25, 2018 at 2:23pm
whats the meaning of this type of vector?
 
std::vector<int> g{ { 1,2,3,4 } };
Last edited on Apr 25, 2018 at 2:24pm
Apr 25, 2018 at 3:17pm
It is an explicit call of the constructor that takes an initializer list. See:

http://www.cplusplus.com/reference/vector/vector/vector/

C++11 (6)

Depending on the compiler, it might work without the inner {}.
Apr 25, 2018 at 6:02pm
If it's C++11 compliant, it will work without the inner {}. Shouldn't be up to chance, or the compiler is just wrong. And I think all the major compilers are good by now. I emphasize this only so that it's clear this isn't just some non-portable compiler-specific feature; this is the core language.
Apr 26, 2018 at 4:48pm
I'm using the visual studio 2017
Last edited on Apr 27, 2018 at 9:48am
Apr 26, 2018 at 8:14pm
That compiles fine for me on Visual Studio 2015, with or without the inner {}. I don't see why it would stop working in Visual Studio 2017, but I can't test that right now.

What is your exact, full error message..?

Edit: Please still provide your error message, but it seems that there are some bugs with IntelliSense in VS17.
https://developercommunity.visualstudio.com/content/problem/207122/c-intellisense-not-working-within-an-initializer-l.html

However, IntelliSense is not the compiler. Try to still compile it, and let us know if it works.
Last edited on Apr 26, 2018 at 8:28pm
Apr 26, 2018 at 11:29pm
yes exactly it has a bugs when I run this code in visual studio 2017
Apr 26, 2018 at 11:31pm
Okay, so What is your exact, full error message..?

If it's running, but you're getting "bugs", describe the bugs in more detail.

Also, why even bother using an initialization list if you just re-assign the values...? (lines 13, 14, 15)
Last edited on Apr 26, 2018 at 11:32pm
Topic archived. No new replies allowed.