示例程序:
#include <iostream>
#include <stdio.h>
int main()
{
int a[3][4] = {
{1,2,3,4},
{2,3,4,5},
{3,4,5,6}
};
int b[3][4] = {
{10,11,12,13},
{11,12,13,14},
{12,13,14,15}
};
int(*aa[2])[4] = { a,b };
int* p1[3] = {a[0],a[1],a[2]};
int* p2[3] = {b[0],b[1],b[2]};
int** pp[2] = { p1,p2 };
int*** p = pp;
printf("%d\n", (*(*p + 2))[1]); //a[2][1]
printf("%p %p\n", aa[1][2] ,aa[1][0]);
printf("%ld\n", aa[1][2] - aa[1][0]); //b[2]- b[0]
std::cout << "Hello World!\n";
}
内存位置示意图:
运行结果: