Initialize a vector for C ++ / C ++ 11 zeros

I know that in C ++ 11 they added a function to initialize a variable to zero as such

double number = {}; // number = 0 int data{}; // data = 0 

Is there a similar way to initialize std::vector fixed length for all zeros?

+48
c ++ c ++ 11
Oct 28
source share
1 answer

For this you do not need initialization lists:

 std::vector<int> vector1(length, 0); std::vector<double> vector2(length, 0.0); 
+106
Oct 28
source share



All Articles