VB.net无法继承

乔治·弗格

我对VB.net相当陌生,我无法编译此代码,也无法理解为什么。

MustInherit Class Poligono

    Protected p_cant_Lados As Integer
    Public Property cant_Lados() As Integer
        Get
            Return p_cant_Lados
        End Get
        Set(ByVal value As Integer)
            p_cant_Lados = value
        End Set
    End Property

    Public MustOverride Function obtenerPerimetro()
    Public MustOverride Function cargarLados()

End Class

Public Class Triangulo
    Inherits Poligono

    Private lado1 As Integer
    Private lado2 As Integer
    Private lado3 As Integer

    Public Function cargarLados() As Object
        Return 1
    End Function

    Public Function obtenerPerimetro() As Object
        Return 1
    End Function

End Class

错误2'Triangulo'无法从类'Poligono'继承,因为它扩展了基类对程序集的访问。c:\ users \ win7 \ documents \ visual studio 2013 \ Projects \ WindowsApplication1 \ WindowsApplication1 \ Form1.vb 33 14 WindowsApplication1

谢谢!

塞尔格

默认情况下,在名称空间级别声明的类将获得Friend访问级别所以PoligonoFriend ClassFriend类可能不可见向一般公众。

更改

MustInherit Class Poligono

Public MustInherit Class Poligono

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章