クラスが使えないときでもオブジェクト指向する

  • タグ:
  • タグはありません
Const psnName=0
Const psnAge=1
Const psnHeight=2

Function NewPerson(name,age,height)
	Dim this(2)
	this(psnName)=name
	this(psnAge)=age
	this(psnHeight)=height
	NewPerson=this
End Function

Sub NewRefPerson(byRef this,name,age,height)
	ReDim this(2)
	this(psnName)=name
	this(psnAge)=age
	this(psnHeight)=height
End Sub

Sub printStat(this)
	WScript.Echo Join(Array( _
		"Name: ",this(psnName)," ", _
		"Age: ",this(psnAge)," ", _
		"Height: ",this(psnHeight) _
	),"")
End Sub

Dim bob
bob=NewPerson("Bob",23,168.2)
printStat bob

Dim kate
NewRefPerson kate,"Kate",14,145.6
printStat kate