15,611,482 members
See more:
Sorry for my question,but I'm getting confused with a simple things.

define type Vector<int> VecIdx,

(VecIdx & Vector) Is a vector of vector or a vector of vector of vector. I know my question is a naive question,sorry for that.

What I have tried:

```Define type     Vector<int>    VecIdx,

(VecIdx & Vector) <pre>```
Posted
Updated 15-Jul-21 10:36am
v2
jeron1 15-Jul-21 11:10am
Richard MacCutchan 15-Jul-21 12:02pm
"(VecIdx & Vector) Is a vector of vector or a vector of vector of vector."
No, because none of what you have posted is valid C++ code.
Member 15181211 15-Jul-21 13:46pm
I defined a header file which contains data like this
Typedef std::vector<size_t> VecIdx_t.
So wherever I want to define a vector of type size_t I use VecIdx_t.
My question somehow deals with vector of vector and vector of vector of vector. For example if I have a triple vector. I don't know how to access each vector if I have a vector of vector of vector
Richard MacCutchan 16-Jul-21 3:09am
That does not really explain what problem you are trying to solve; perhaps if you showed some code is would help. But creating a vector of vectors is a simple matter:
```std::vector<std:vector<int>> vec1; // is a vector of vectors
std::vector<std:vector<std:vector<int>>> vec2; // is a vector of vectors of vectors
```

## Solution 1

Writing complex code is often a result of not understanding the language or the to solving problem.

So you better be read and understand the vector reference to be really sure you are understand using the class. Like hammering with a pliers is more a "bush fix" than a good idea for a craftsman. ;-)

PS: my experience is that learning the basics is always well spend time, because it prevents you making wrong decisions.

## Solution 2

I am a fan of the `using` and `typedef` statements. They are pretty close to the same thing for this purpose although the `using` statement has quite a bit more capability.

For this you can add some statements to define the types in layers. Let's say you want a vector of vectors of vectors of data. Here's how that might look.
C++
```using vdata   = std::vector< data >;
using vvdata  = std::vector< vdata >;   // a vector of vectors
using vvvdata = std::vector< vvdata >;  // a vector of vectors of vectors

// one instance of it :

vvvvdata MyVector;```
The equivalent `typedef` statement for the first `using` statement there is :
C++
`typedef std::vector< data >  vdata;`
As you can see, they are essentially backwards from each other and `typedef` does not use an equals sign.

v2