multidimensional arrays

A

asdf

I was told not to use the low-level language such as arrays which
inherited from C, I want to know what can I use to substitute the
C-style multidimensional arrays? Is there multidimensional vector?
 
K

Kai-Uwe Bux

asdf said:
I was told not to use the low-level language such as arrays which
inherited from C, I want to know what can I use to substitute the
C-style multidimensional arrays? Is there multidimensional vector?

E.g.,

std::vector< std::vector< int > >


Best

Kai-Uwe Bux
 
J

Jim Langston

asdf said:
I was told not to use the low-level language such as arrays which
inherited from C, I want to know what can I use to substitute the
C-style multidimensional arrays? Is there multidimensional vector?

The usually way is to do a vector of vectors, but I find that troublesome,
and usually wind up encapsulating the 2nd vector. Something like:

struct MyList
{
std::vector<int> IntVector;
};

std::vector<MyList> My2DArray;

I just find the syntax a bit easier than
std::vector<std::vector<int> > My2DArray;
 
F

fightwater

Jim Langston 写é“:
The usually way is to do a vector of vectors, but I find that troublesome,
and usually wind up encapsulating the 2nd vector. Something like:

struct MyList
{
std::vector<int> IntVector;
};
Why use a struct here, why not just do
 
F

Frederick Gotham

asdf posted:
I was told not to use the low-level language such as arrays which
inherited from C, I want to know what can I use to substitute the
C-style multidimensional arrays? Is there multidimensional vector?


Long live inefficient code!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top