结构体赋值或者传值的时候是复制一个副本
#include<iostream.h>
#include<stdio.h>
typedefstruct st{
int i;
int j;
};
intmain()
{
sts,p;
s.i=1;
s.j=1;
cout<<s.i<<""<<s.j<<endl;
p=s;
p.i=2;
p.j=2;
cout<<s.i<<""<<s.j<<endl;
getchar();
}
1 1
1 1
为无为,事无事 / 天下难事,必作于易
#include<iostream.h>
#include<stdio.h>
typedefstruct st{
int i;
int j;
};
intmain()
{
sts,p;
s.i=1;
s.j=1;
cout<<s.i<<""<<s.j<<endl;
p=s;
p.i=2;
p.j=2;
cout<<s.i<<""<<s.j<<endl;
getchar();
}
1 1
1 1