Question
We've seen that C++ stores statically-allocated multidimensional arrays in first-dimension-major order . Suppose, instead, that C++ stored them using last-dimension-major order (so, the opposite) instead.
We've seen that C++ stores statically-allocated multidimensional arrays in first-dimension-major order. Suppose, instead, that C++ stored them using last-dimension-major order (so, the opposite) instead. For example, suppose we had this statically-allocated array:
int a[3][2][2];
then suppose that its elements were stored contiguously in memory in exactly the following order which, again, is different from how C++ normally does it.
a[0][0][0]
a[1][0][0]
a[2][0][0]
a[0][1][0]
a[1][1][0]
a[2][1][0]
a[0][0][1]
a[1][0][1]
a[2][0][1]
a[0][1][1]
a[1][1][1]
a[2][1][1]
If that was the rule in C++, then which of the following function declarations would we expect to be illegal? For each one that you would expect to be illegal, explain in a sentence or two why. (Note that I'm asking this question generally, so the answer is never going to be "Because the capacity of x is not the same as the capacity of a in your example.")
void func1(int x[10][3]) void func2(int x[][10][20]) void func3(int x[30][]) void func4(int x[40][][][]) void func5(int x[][10][]) void func6(int x[10][][20])
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started