1. ## Programmatically declare vectors

I wonder if it is possible to programmatically declare vectors.

For example if I will return a number from somewhere wich could be 15.
Then I want programmatically declare 15 different vectors.

Code:
```int Number = 0;

Number = 15; //Returned Number

//Is it possible to programmatically here declare Num1 to Num15(15 vectors)
//in any way ?
std::vector<double> Num1;```

2. 15 different vectors, or one vector with 15 elements? The vector constructor can take a size.

3. Why would you want to? Do you need an array of arrays (basically)?
Then it is possible to make a vector of vectors:
std::vector< std::vector<double> > myvec(Number);

But the vector itself is a dynamic array, not just a single variable.

4. Yes, I forgot to mention. I meen 15 different vector like this and then not elements:

Code:
```std::vector<double> Num1;
std::vector<double> Num2;
std::vector<double> Num3;
...
... until:
std::vector<double> Num15;```

5. Then make a vector of vectors. Something like vector< vector<double> >.

6. Why I want to do that is because if my program will return in this case number 15. Then this number will stand for how many files there is in a folder ex.
Then I want to read in each file in each vector. 1 - 15.
Perheps this is not possible but there is an other approach to it.

Make a vector of vector, isn&#180;t that by creating dimensions of the vector ?

7. Mine and tabstop's suggestion will work for this. Make a vector of vectors.

8. I understand.. I just have to check if this solution will be good/ possible if I need to declare about 20 000 vectors.
Yes that is much

9. Originally Posted by franse
Why I want to do that is because if my program will return in this case number 15. Then this number will stand for how many files there is in a folder ex.
Then I want to read in each file in each vector. 1 - 15.
Perheps this is not possible but there is an other approach to it.

Make a vector of vector, isnīt that by creating dimensions of the vector ?
Why would want a vector of vectors, then? Wouldn't you want a vector of file_data_structure (whatever you're using)? Even if you are using a vector for each file, you could typedef it so that people (and you!) know what's going on.

10. I haven&#180;t worked to much by doing vectors out of vector. Using typedef should look something like this, I think:
Code:
```typedef vector<std::string> string1;
typedef vector<string1> string2;
typedef vector<string2> string3;

String3 Three;```
By doing that, I have created 3 dimensions and if I will have like 5000 of these dimension, I am not sure if that will be difficult to know which dimension was for what or perheps it is.

11. If you have 5000 dimensions, you have way way way way way way way way way way bigger problems.

12. That is what I am a bit afraid of. What problem are you thinking of, is it memory problems, that it will take up much RAM ?
(I will fill each vector or dimension with say 50 lines &#225; 1 line = 50 characters from a file.)

13. 5000 dimensions!!!
I'm pretty sure you don't know what that actually means.
I've never needed to use more than about 3 dimensions in my life.

14. I think that perhaps you do not need to read the entire file contents into memory. Waste of memory and cpu time.
Each vector can hold an entire file. So you will simply want ONE vector that can hold the vector who holds the file contents. Get me?

15. There's a limit on the number of dimensions, but I don't know what it is. If you have 5000 dimensions that means you have seriously done something wrong with your data structure.