fortran 2003中类型和类之间的区别 [英] Difference between type and class in fortran 2003

查看:196
本文介绍了fortran 2003中类型和类之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人告诉我要攻读博士学位,我必须学习fortran 2003语言.我之前从未使用过和OOP程序,也从未使用过fortran.我试图了解类型和类之间的区别是什么.我知道类是使用'TYPE'关键字声明的,但是我也看到了使用关键字'CLASS'的示例,因此我感到困惑.希望有道理.

I have been told for my PhD that I have to learn fortran 2003 language. I have never used and OOP program before nor fortran. I am trying to understand what the difference between type and class is. I know that classes are declared with the 'TYPE' keyword but I have also seen examples of the keyword 'CLASS' being used used so I am getting confused. Hope that makes sense.

推荐答案

关键字type用于声明派生的类型-最好不要养成思考的习惯,也许是从外国语言,type用于声明称为classes的内容.

The keyword type is used to declare derived types -- best not to get into the habit of thinking, perhaps imported from foreign languages, that type is used for declaring something called classes.

在受限情况下,关键字class用于表示of the type specified or any of its extended types. 扩展类型是Fortran的意思,它是扩展另一种类型的本质,本质上是专业继承自另一种类型的类型.在过程伪参数列表中以及在具有属性allocatable或属性pointer的实体的声明中,使用class的受限情况. class实体在运行时获取动态type,其动态类型可能因运行而异,或者在程序的一次执行中有所不同.

The keyword class is used, in restricted circumstances, to mean of the type specified or any of its extended types. extended type is Fortran-speak for a type which extends another type, essentially one which specialises or inherits from another type. The restricted circumstances within which class is used are in procedure dummy-argument lists and in declarations of entities with the attribute allocatable or the attribute pointer. A class entity gets a dynamic type at run-time, and its dynamic type may vary from run to run, or across a single execution of the program.

如果您不理解前几段中的解释,则可能是因为我的解释不充分,但也可能是因为您对Fortran的基础知识还没有足够的基础.要获得基础知识,请先找到最新的在线教程,在线参考指南,然后开始编程.

If you don't understand the explanation in the previous paragraphs it's possibly because I've explained things poorly, but it's also possibly because you don't yet have enough of a grounding in the basics of Fortran. To acquire the grounding find yourself an up-to-date online tutorial, an online reference guide, and start programming.

这篇关于fortran 2003中类型和类之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆