- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am a bit puzzled with the accessibility of derived type components with PRIVATE attribute.
In the program below,
- when PRIVATE attribute is set as a statement, I got compile errors even for the access from subroutines inside the module. ("error #6292: The parent type of this field is use associated with the PRIVATE fields attribute [30.0]")
- While adding PRIVATE attribute as an option to REAL statement, I get no error but then I can access to the component variables by assignment. (t = t_test(10.0, 20.0))
I have two questions;
- Is there any difference between the two ways of setting accessibility attribute?
- Is the assignment by structure constructor allowed for PRIVATE components?
Thanks in advance!
[bash]MODULE m_type IMPLICIT NONE PRIVATE PUBLIC :: t_test TYPE :: t_test ! PRIVATE ! REAL :: x, y REAL, PRIVATE :: x, y CONTAINS PROCEDURE, PUBLIC :: pr PROCEDURE, PUBLIC :: set END TYPE t_test CONTAINS SUBROUTINE pr(this) CLASS(t_test), INTENT(IN) :: this PRINT *, this%x, this%y RETURN END SUBROUTINE pr SUBROUTINE set(this, that) CLASS(t_test), INTENT(OUT) :: this TYPE (t_test), INTENT(IN ) :: that this%x = that%x this%y = that%y RETURN END SUBROUTINE set END MODULE m_type PROGRAM test USE m_type IMPLICIT NONE TYPE (t_test) :: t t = t_test(10.0, 20.0) CALL t%pr() CALL t%set( t_test(30.0, 40.0) ) CALL t%pr() STOP END PROGRAM test[/bash]
Link Copied
0 Replies

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page