Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make multiple vectors in c++

Brief :-

How to make multiple vectors ?
We generally make vectors using – vector<int> vector_name;
But any method to make multiple vectors at once ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I assume that you’re trying to create multiple vector at once and store them. You can use a simple for loop, or use a vector of vectors!
For example:

#include <vector>

// Using a for loop
#define VECTOR_COUNT 5
std::vector<int> myFiveVectors[VECTOR_COUNT];
for(int i = 0; i < VECTOR_COUNT; i++)
    myFiveVectors[i] = {1, 2, 3};

// Using vector of vectors
std::vector<std::vector<int>> myVectors{};
myVectors.push_back({1, 2, 3});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading