Fortran Coder

标题: 自定义类型,又是数组时,变量如何选取?ps 菜鸟一个 [打印本页]

作者: duter    时间: 2015-6-14 19:49
标题: 自定义类型,又是数组时,变量如何选取?ps 菜鸟一个
[Fortran] 纯文本查看 复制代码

module typedef
implicit none
type ::player
real:: angle
real:: speed
real:: distance
end type
end module

program main
  use shoot
  implicit none
  integer,parameter::players=2
  type(player)::people(players)=(/player(30.0,25.0,0.0),player(45.0,20.0,0.0)/)

  红色部分为什么不用people
即最后一行代码写成如下形式是错误的:
  type(player)::people(players)=(/people(30.0,25.0,0.0),people(45.0,20.0,0.0)/)

作者: fcode    时间: 2015-6-14 22:12
因为 player 才是 type 的类
people 是变量名,不是type名

type 的常量就是这样定义的,语法就规定。




欢迎光临 Fortran Coder (http://bbs.fcode.cn/) Powered by Discuz! X3.2