#include #define N 10 // 定义常量 using namespace std; typedef int TenArr[N]; TenArr &new_arr() { static int m[N] = {0}; // 全局静态区存储,程序结束后才释放 for (int i = 0; i < N; i++) { m[i] = i; } return m; } int main() { TenArr &p = new_arr(); int i = 0; while (i < N) { cout << "p[" << i << "] = " << p[i++] << endl; } return 0; }