jeudi 5 septembre 2019

Initialize a 2D vector to zeros C++/C++11 [duplicate]

This question already has an answer here:

I know how to initialize a 1D std::vector with zeros. What is the simplest way to initialize a 2D vector? I only found something like this:

std::vector<int> vector1D(length, 0);
std::vector<int> vector2D(length, vector1D);

Is there any way without defining an auxiliary variable (vector1D)?

Aucun commentaire:

Enregistrer un commentaire