C/C++代码解释

typedef struct Dataytpe
{
int m;
int Identity;
char Name[20];
int total;
int record[10][2];
}Datatype;
typedef struct Listnode
{
Datatype customer;
struct Listnode *next;
}Listnode,*Linklist;

void printinfo(Linklist &p)
{
int i=0,j=0;
printf(" *********查询结果*********\n");
printf(" 消费编号%d\n",p->customer.m);
printf(" 学号:%d\n",p->customer.Identity);
printf(" 姓名:%s\n\n",p->customer.Name);
printf(" 消费日期 消费金额\n");
这是项目的一部分代码,这里面“->”代表什么意思?“p->customer.Identity”什么意思?求解前辈解答一下,最好详细一点。谢谢,感激不尽。在线等!
for(i=0;p->customer.record[i][0]>0;i++)
{
for(j=0;j<=1;j++)
{
printf(" %-11d",p->customer.record[i][j]);
}
printf("\n");
}
printf("\n 消费总额 %d\n",p->customer.total);
printf(" **************************\n");
return;
}

typedef struct Dataytpe {
int m;
int Identity;
char Name[20];
int total;
int record[10][2];
}Datatype;

typedef struct Listnode {
Datatype customer; 
struct Listnode *next;
}Listnode,*Linklist;


void printinfo(Linklist &p) {
int i = 0,j = 0;
printf(" *********查询结果*********\n");
printf(" 消费编号%d\n",p->customer.m);
printf(" 学号:%d\n",p->customer.Identity);
printf(" 姓名:%s\n\n",p->customer.Name); 
printf(" 消费日期 消费金额\n");
//这是项目的一部分代码,这里面“->”代表什么意思?“p->customer.Identity”什么意思?求解前辈解答一下,最好详细一点。谢谢,感激不尽。在线等!
//存取结构成员时,需要用操作符来控制,比如给构造变量a的成员Total赋值时,语句是a.Total = 369.25,但当结构变量是指针时,操作符是->,如b->Total = 369.25
for(i = 0;p->customer.record[i][0] > 0;i++) {
for(j = 0;j <= 1;j++) {
printf(" %-11d",p->customer.record[i][j]);
}
printf("\n");
}
printf("\n 消费总额 %d\n",p->customer.total);
printf(" **************************\n");
return;
}

追问

不知道怎么称呼您,首先,谢谢您!还有一个问题,void printinfo(Linklist &p) 这怎么解释?括号里面的这两个叫参数?括号里的怎么解释?是属于那一部分知识?谢谢,详细解答一下。谢谢

追答

语句void printinfo(Linklist &p)中,这是函数头声明语句,操作符&表明,传递的是p的地址,也就是按址传递。要注意的是,当在函数调用语句中出现操作符&时,表明的是,按引用传递(C++所有)。

温馨提示:答案为网友推荐,仅供参考
相似回答