+ 1
What is int k{1}; in c++ ?
8 Answers
+ 3
That is a new way to initialize variables in C++11.
+ 4
In C++11 you can use int k{}; instead of int k = 0;.
int k{}; may not work unless C++11 standard is enabled.
+ 3
It would. The example in my lessons is
vector<int> number {6, 5, 4, 3};
cout << number [2];
I'm not sure on the array initialization. I don't have C++11 on my mobile to test it.
+ 2
It is equivalent to "int k = 1;" in this context.
+ 1
thanks for the explanation guys :)