#include <iostream>
using namespace std; const int MAX = 8; int main () { int var[MAX] = {10, 100, 200,2,3,5,7,11}; int *ptr[MAX]; for (int i = 0; i < MAX; i++) { ptr[i] = &var[i]; // assign the address of integer. } for (int i = 0; i < MAX; i++) { cout << "Value of var[" << i << "] = "; cout << *ptr[i] << endl; } return 0; }
https://www.tutorialspoint.com/cplusplus/cpp_array_of_pointers.htm
转载于:https://www.cnblogs.com/poission/p/10860807.html