VB.Net中文教程(2) 继承与封装性(4)
Public Sub New()
MyBase.New()
Form1 = Me
"This call is required by the Win Form Designer.
InitializeComponent()
"TODO: Add any initialization after the InitializeComponent() call
End Sub
"Form overrides dispose to clean up the component list.
Public Overrides Sub Dispose()
MyBase.Dispose()
components.Dispose()
End Sub
#Region " Windows Form Designer generated code "
.......
#End Region
Protected Sub Form1_Click( ByVal sender As Object,
ByVal e As System.EventArgs)
Dim p1 As New FullTime_Teacher("David", 25)
p1.Show()
p1.modifyValue("Kent Smith", 45)
p1.Show()
End Sub
End Class
此程序输出:
Name: David Age: 25
Name: Kent Smith Age: 45
Show()是Person类别的Public程序,孙子类别FullTime_Teacher继承之,成为FullTime_Teacher类别的Public程序,所以Form1_Click()程序能写着指令:p1.Show()。name和modifyAge()是Person的Protected成员,Teacher的modify()程序里能直接使用它们。而且FullTime_Teacher的modifyData()程序里能直接使用它们。但是Form1_Click()就无法使用它们。modify()是Teacher的Protected成员,FullTime_Teacher的modifyValue()程序里能直接使用它们,但Form1_Click()就不行使用。所以若将上述Form1_Click()的指令改为如下,就不对了:
Protected Sub Form1_Click( ..... )
Dim p1 As New FullTime_Teacher("David", 25)
p1.Show()
p1.modify("Kent Smith", 45) "Error!
p1.modifyAge(24) "Error!
p1.Show()
End SubEnd Class
责任编辑:Lily
| SA空口令破解和保护 |
| 怎样使MySQL更安全? |
| Mysql数据库的安全配置、实用技巧 |
| 如何安全的配置和应用MySQL数据库? |
| Oracle数据库安全策略分析 |
| SQL Server 2000的安全配置 |
| 使一个新的MySQL安装更安全 |
| 教您如何安全的应用MySQL |
| MySQL数据库安全配置 |
| MySQL安全性指南(1) |
| MySQL安全性指南(2) |

