#include "stdafx.h"
#include<iostream>
#include<cstring>
//构造结构
struct antarctica_year_end
{
int year;
};
int main()
{
//类型组合
using namespace std;;
antarctica_year_end s01, s02, s03; //创建类型变量
s01.year = 1998; //成员运算符访问成员
antarctica_year_end *pa = &s02; //结构指针
pa->year = 1999;
antarctica_year_end trio[3]; //创建结构数组
trio[0].year=2003; //运算符访问数组成员
cout<< trio->year <<endl;
const antarctica_year_end *arp[3] ={&s01, &s02, &s03}; //创建指针数组
cout<< arp[1]->year <<endl;
const antarctica_year_end **ppa = arp; //创建指向上述数组的指针
auto ppb = arp;
cout<< (*ppa)->year<<endl;
cout<<(*(ppb+1))->year <<endl;
return 0;
}
类型组合(数组、指针)
最新推荐文章于 2022-10-25 17:00:10 发布