//#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int a[10];
int(*at1)[10]; //定义一个指向数组类型的数组类指针
at1 = &a;
(*at1)[0] = 1;
cout << a[0] << endl;
typedef int(type_array)[10]; //定义一个数组类型
type_array at2; //数组at2, at3...
at2[0] = 2;
cout << at2[0] << endl;
typedef int(*type_p_array)[10]; //定义一个指针数组类型
type_p_array at3;
at3 = &a;
(*at3)[0] = 3;
cout << *at3[0] << endl;
system("pause");
return 0;
}
C++数组类指针的基本语法
最新推荐文章于 2025-05-02 00:49:00 发布
本文通过几个示例介绍了 C++ 中数组和指针类型的定义方式,包括直接定义数组、使用 typedef 定义数组类型以及定义指针数组类型的方法。
2649

被折叠的 条评论
为什么被折叠?



