[jass]
library A  //错误代码(命名为"代码1")
  globals
     B array test
  endglobals
  struct B
     public integer a
     public integer b
    
     method ab takes integer a1 , integer b1 returns nothing
         set this.a = a1
         set this.b = b1
         call BJDebugMsg(I2S(this.a))
         call BJDebugMsg(I2S(this.b))
     endmethod
    
     method create takes nothing returns nothing
       call DisplayTextToPlayer(Player(0),0,0,"111")
     endmethod
  endsturct
endlibrary
function go takes nothing returns nothing
  set test[1] = B.craete()
  call test[1].ab(10,20)
endfunction
[/jass]
[jass]
library A  //正确代码(命名为"代码2")
  globals
     B array test
  endglobals
  struct B
     public integer a
     public integer b
    
     method ab takes integer a1 , integer b1 returns nothing
         set this.a = a1
         set this.b = b1
         call BJDebugMsg(I2S(this.a))
         call BJDebugMsg(I2S(this.b))
     endmethod
    
     method create takes nothing returns nothing
     endmethod
  endsturct
endlibrary
function go takes nothing returns nothing
  set test[1] = B.craete()
  call test[1].ab(10,20)
endfunction
[/jass]
请问...为什么 构造函数 create() 加一条函数 就会是错误的 不加就没问题呢- -....
请说明一下 构造函数吧...谢谢 |