Is it possible to declare an array consisting of other arrays (with variable sizes) consisting of structs in C++? It would be really nice if there was an easy and efficient way (using for) to iteration over all structs inside an element of the array.
The struct is defined like this:
struct Number
{
int x;
int y;
};
For example, the data is something like:
{
{ {0,0}, {0,1} },
{ {0,0}, {0,1}, {1,0}, {0,0} },
{ {0,0}, },
{ {0,0}, {4,0} }
}
I would like to use this for a self made clock consisting of an Arduino Uno, an Ethernet shield, an RTC and a LED array. The solution shouldn't use more memory than needed. That's why I don't use a two dimensional array.
std::vector<std::vector<Number>>, you're probably left on providing your own implementation for it.C++ Standard Library. Maybe you can find another library that implements something similar to astd::vector.Number N0[] = { {0,0}, {1,1}, {2,2}, {4,4} }; Number N1[] = { {6,0}, {1,3}, {1,2} }; Number N2[] = { {7,0}, {1,2}, {0,2}, {4,8}, {6,6} }; Number *Numbers[] = { N0, N1, N2 };But then I don't know how to iterate through the elements of Numbers[0]; So Numbers[0][0]->x gives me 0,0 and Numbers[0][1]-x gives me 1.