结构体赋值或者传值的时候是复制一个副本

#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

posted on 2011-05-28 18:05  xuq  阅读(185)  评论(0编辑  收藏  举报

导航