Defining an array of arrays

A

Andy Ganczak

I want to create a data structure in which a 2x2 array contains elements
that themselves are arrays and integers.

array[x][y] 0 1 2 ...
0 array1[a] array2 array3[d]
1 array4[e] array5[f] array6[r]
2 array7[t] integer1 ...
...

Is this possible and how would I go about doing it efficiently?

Thanks in advance for any help you may have!
 
A

Alf P. Steinbach

* Andy Ganczak:
I want to create a data structure in which a 2x2 array contains elements
that themselves are arrays and integers.

That sounds like an imagined solution to some problem.

What is the problem?

array[x][y] 0 1 2 ...
0 array1[a] array2 array3[d]
1 array4[e] array5[f] array6[r]
2 array7[t] integer1 ...
...


This is larger than a 2x2 array, inconsistent with the explanation.

Is this possible and how would I go about doing it efficiently?

Represent the integers as single-item arrays. Use std::vector
instead of raw arrays.
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,074
Latest member
StanleyFra

Latest Threads

Top