回 帖 发 新 帖 刷新版面

主题:结构体中可变数组问题

type  job_info
INTEGER name
INTEGER,allocatable::children(:)
INTEGER parent
integer num_children
integer num_pro
integer level
end type job_info

。。。      

type(job_info),allocatable::job(:),last_job(:)

。。。   

allocate(job(m),last_job(m))

先将job中各个分量都赋值后,然后last_job=job

为了满足程序功能的需要,要对job中的children进行修改,但是我希望last_job的值不变,为什么last_job中的children也随之改变呢????

 

跪求高手指点迷津!多谢!!!!

回复列表 (共2个回复)

沙发


是不是因为没有allocate (last_job.children)?
last_job.children与job.children公用了一段内存空间

板凳


原来就是这个原因,犯了低级错误[em8]

我来回复

您尚未登录,请登录后再回复。点此登录或注册