親と子の2つのクラスがあります。
Class Test
Private Test_Text
Private Sub Class_Initialize()
Test_Text = "Hello"
End Sub
Private Sub Class_Terminate()
End Sub
Public Property Get Text
Text = Test_Text
End Property
Public Property Let Text(ByVal strIn)
Test_Text = strIn
End Property
End Class
Class SubTest
Public SubTest_Test
Private SubTest_Interger
Private Sub Class_Initialize()
Set SubTest_Test = New Test
End Sub
Private Sub Class_Terminate()
Set SubTest_Test = Nothing
End Sub
Public Property Get int
int = SubTest_Integer
End Property
Public Property Let int(ByVal intIn)
SubTest_Integer = intIn
End Property
End Class
SubTest_Test を public にしたので、このように子クラスからアクセスできます
Set MyTest = New SubTest
MsgBox MyTest.SubTest_Test.Text
これは受け入れられますか、それとも SubTest_Test を非公開にし、子クラスにプロパティを記述して親プロパティにアクセスする必要がありますか?
編集:親に直接アクセスする際にセキュリティ/ユーザビリティの問題があるかどうかという質問があったはずです。
考えれば考えるほど、使いやすさの観点から考えると、子クラスを使用する人から親を非表示にする方がよいでしょう。そうすれば、子クラスからオブジェクトを作成するときに、親クラスについて何も知る必要はありません。