小编J P*_*J P的帖子

VBScript中的类:为什么这两个例子做同样的事情?

我在这个StackOverFlow问题,VBScript中的对象/类的字典中找到了这段代码.

我的问题是为什么这个"短"课与这个"长"课做同样的事情?为什么甚至打扰长码?短类版本可以与同一类中的其他方法一起使用吗?谢谢!

短班

Class employeeclass
    Public first, last, salary
End Class
Run Code Online (Sandbox Code Playgroud)

长班

Class employeeclass
    Private m_first
    Private m_last
    Private m_salary

    Public Property Get first
        first = m_first
    End Property
    Public Property Let first(value)
        m_first = value
    End Property

    Public Property Get last
        last = m_last
    End Property
    Public Property Let last(value)
        m_last = value
    End Property

    Public Property Get salary
        salary = m_salary
    End Property
    Public Property Let salary(value)
        m_salary = value
    End Property
End Class
Run Code Online (Sandbox Code Playgroud)

但是,使用短类的完整脚本,只需用long类替换短类就可以获得相同的结果.

Class …
Run Code Online (Sandbox Code Playgroud)

vbscript class object

3
推荐指数
2
解决办法
1万
查看次数

标签 统计

class ×1

object ×1

vbscript ×1