question

whats the meaning of this type of vector?
 
std::vector<int> g{ { 1,2,3,4 } };
Last edited on
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 {}.
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.
I'm using the visual studio 2017
Last edited on
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
yes exactly it has a bugs when I run this code in visual studio 2017
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
Topic archived. No new replies allowed.