简体   繁体   中英

C++ Dereferencing array

I have a 3 dimension array, the third dimension refers to existing arrays:

int FrontStep[12]{
90,90,90,90,
35,50,66,81,
115,122,119,115
};


int (*Move[100][4])[12];

Move[0][0] = &FrontStep;

Those are co-ordinates for Bezier curves for a quadruped and I wish to extract them back in one piece instead of pieces.

I know how to get a single coordinate:

int x = *Move[0][0][0];

But what I would like to get is the whole array for, in this case, FrontStep.

int M = Move[0][0] ???????

What is the syntax for that? I've been studying arrays of arrays in C++ for a while now, and my understanding is still mired in confusion!

Option #1

int (&M)[12] = *Move[0][0];
//   ^         ^
std::cout << M[0];

Option #2

int (*M)[12] = Move[0][0];
//   ^
std::cout << (*M)[0];
//            ^

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM