- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我开始使用现代 Fortran 的面向对象功能,并且已经熟悉其他语言的面向对象。在 Delphi (Object Pascal) 中,通常会在其覆盖的后代过程中调用过程的祖先版本,甚至有一个“继承”的语言语句允许这样做。我找不到等效的 Fortran 构造 - 但可能正在寻找错误的东西。请参阅下面的简单示例。非常感谢任何建议。
type tClass
integer :: i
contains
procedure Clear => Clear_Class
end type tClass
type tSubClass
integer :: j
contains
procedure Clear => Clear_SubClass
end type tSubClass
subroutine Clear_Class
i = 0
end subroutine
subroutine Clear_SubClass
inherited Clear ! this is the Delphi way
j = 0
end subroutine
最佳答案
下面是一些示例代码,尝试通过@HighPerformanceMark 实现注释(即,子类型具有引用父类型的隐藏组件)。
module testmod
implicit none
type tClass
integer :: i = 123
contains
procedure :: Clear => Clear_Class
endtype
type, extends(tClass) :: tSubClass
integer :: j = 456
contains
procedure :: Clear => Clear_SubClass
endtype
contains
subroutine Clear_Class( this )
class(tClass) :: this
this % i = 0
end
subroutine Clear_SubClass( this )
class(tSubClass) :: this
this % j = 0
call this % tClass % Clear() !! (*) calling a method of the parent type
end
end
program main
use testmod
implicit none
type(tClass) :: foo
type(tSubClass) :: subfoo
print *, "foo (before) = ", foo
call foo % Clear()
print *, "foo (after) = ", foo
print *, "subfoo (before) = ", subfoo
call subfoo % Clear()
print *, "subfoo (after) = ", subfoo
end
给出(使用 gfortran-8.2)
foo (before) = 123
foo (after) = 0
subfoo (before) = 123 456
subfoo (after) = 0 0
如果我们注释掉标有 (*) 的行,subfoo % i
将保持不变:
foo (before) = 123
foo (after) = 0
subfoo (before) = 123 456
subfoo (after) = 123 0
关于fortran - 现代 Fortran : Calling an ancestor procedure from descendent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55415511/
我有 3 个表: 1. 学生:{id, name, roll} 2. 主题:{id, name} 3. 分数:{student_id, subject_id, marks} 我有一个返回所有学生及其分
我将制作一款完全由程序生成的空间/交易/战斗游戏。但是,我知道将整个星系的所有细节存储在内存中是不可行的。因此,我一直认为我可以使用种子来生成太阳系,并且从该太阳系,您可以使用跳跃门前往其他太阳系。问
我有一个关于 ADS 中存储过程的性能的问题。我创建了一个具有以下结构的简单数据库: CREATE TABLE MainTable ( Id INTEGER PRIMARY KEY,
我想将这个简单的东西加载到我的编辑器中: Write:-repeat,write("hi"),nl,fail. 所以它打印“嗨”。 我该怎么办? 我目前正在尝试做 File->New 并将名为 Wri
在从 c# 调用过程中显示以下错误 "Procedure or function 'CALL get_Users()'cannot be foundin database 'joomla'."` 代码
在网上找到了创建存储过程的教程,只是不明白到底什么时候需要执行创建存储过程。 是否应该在每次重新启动 MySQL 服务器时执行存储过程创建? 我是否需要在每次启动我的应用程序时都执行存储过程创建sql
我有一个包含所有例程的 MySQL 转储。当我恢复时,只有存储过程没有恢复。我从中提取 Dump 的 MySQL 版本是 5.0.77-log,我恢复到的版本是 5.6.12。 感谢任何帮助。 谢谢
我是一家大量使用存储过程(500+)的公司的新手。为了帮助学习系统,我希望有一种简单的方法来构建一个树型列表,显示系统中的所有存储过程以及它们自己调用哪些存储过程......从而创建可以执行的存储过程
我需要使用 mysqldump 和 replace 而不是 insert 并且在恢复时不删除数据库和表。但我需要删除并重新创建触发器和存储过程 为此,我将 mysqldump 与 --replace
在执行代码的过程中,我在不同的Scheme实现中遇到以下错误: Racket : application: not a procedure; expected a procedure that ca
我想将存储过程输出参数映射到一个实体。 例如, PROCEDURE ForExample @ID int, @LastUpdate datetime OUTPUT AS Update EntityTa
假设我有“myStoredProcedure”,它接受一个 Id 作为参数,并返回一个信息表。 是否可以编写类似于此的 SQL 语句? SELECT MyColumn FROM Tabl
我想将整个 sql 查询作为词法参数传递给存储过程,然后执行它。任何建议如何做到这一点? 最佳答案 你可以试试这个: create or replace procedure my_proc(pstri
考虑以下测试用例: { CompilerVersion = 21 } procedure Global(); procedure Local(); begin end; type TP
在 Azure Cosmos Db 中,是否可以从另一个存储过程调用一个存储过程?那么UDF呢?我可以从另一个 UDF、存储过程或触发器调用一个 UDF吗? 最佳答案 is there a way t
在 Azure Cosmos Db 中,是否可以从另一个存储过程调用一个存储过程?那么UDF呢?我可以从另一个 UDF、存储过程或触发器调用一个 UDF吗? 最佳答案 is there a way t
在 LINQ to Entities 中,我将存储过程的结果集映射到实体。 在存储过程中,我执行一些更新语句并通过运行 SELECT 查询并将结果集映射到实体来返回结果集。 数据库行得到正确更新,但返
创建存储过程时,BEGIN/END 块是否有用途? 例如, CREATE PROCEDURE SPNAME AS SELECT * FROM TABLE 对比 CREATE PROCEDURE S
正如您在下面看到的,我的过程有两个参数。我希望它们都是整数。但是,当我使用非整数测试该过程时,它仍然可以编译!为什么? create procedure int_arith( p_1 int, p_
我有一个 Client类(class)。在那个类里面有一个数组 losses .首先,我创建并使用客户端填充 clientsColl大批。然后对于该数组中的每个客户端,我填充其 losses大批。 然
我是一名优秀的程序员,十分优秀!