Reference reduces complex notation
// reference variable
//reduce complex notation
#include<iostream.h>
struct date
{
int day,month,year;
};
struct player
{
int no;
char*name;
date dt;
};
player pl[]={
{1,"Aung Aung",{2,12,1987}},
{2,"zaw zaw",{4,5,1990}},
{0}
};
//notice 0 that end player
int main(int argc, char *argv[])
{
player *p=pl;
while(p->no!=0)
{
player& pr=*p;
date& d=pr.dt;
cout<<pr.no<<"\t"<<pr.name<<"\t"<<d.day<<"/"<<d.month<<"/"<<d.year<<endl;
p++;
}
return 0;
}
Comments
Post a Comment