我的代碼中的一行將一個數組分配給一個未分配的數組。我認爲這是一個錯誤,但令我驚訝的是它工作得很好。 program test
implicit none
real, allocatable :: x(:,:)
real :: y(2,2)
y = 1.
x = y
print*, x
end program test
如何在內存方面工作
我想重載一個我想用於多態指針的類型的賦值。我不知道指針在運行時持有的實際子類型。 但下面的示例代碼重新奇怪編譯器錯誤,我得到: module example
type :: base_class
real(4) :: some_garbage
contains
end type
type, extends(base_class) :: sub_class
real