How to initialize 2d vector using constructor in c++?
c++, vector
Solution
In C++ 11 you can initialize a vector of vectors like this:
auto yy = std::vector<std::vector<float>>
{
{20.0, 20.0},
{80.0, 80.0},
{20.0, 80.0},
{80.0, 20.0}
};
Problem
I know how to initialize 1d vector like this ``` int myints[] = {16,2,77,29}; std::vector<int> fifth(myints, myints + sizeof(myints) / sizeof(int)); ``` suppose I have 2d data. ``` float yy[][2] = {{20.0, 20.0}, {80.0, 80.0}, {20.0, 80.0}, {80.0, 20.0}}; ``` How can I initialize a 2d vector ?