Stub methods

Kajik

New Member
Reaction score
4
Hmm, this is realy weird.
I tried an example from jassHelper manual:
JASS:

struct Parent

    stub method xx takes nothing returns nothing
        call BJDebugMsg("Parent")
    endmethod

    method doSomething takes nothing returns nothing
        call this.xx()
        call this.xx()
    endmethod

endstruct

struct ChildA extends Parent
    method xx takes nothing returns nothing
        call BJDebugMsg("- Child A -")
    endmethod
endstruct

struct ChildB extends Parent
    method xx takes nothing returns nothing
        call BJDebugMsg("- Child B --")
    endmethod
endstruct

function test takes nothing returns nothing
 local Parent P = Parent.create()
 local Parent A = ChildA.create()
 local Parent B = ChildB.create()
    //notice the variables are of the 'Parent' type.
    call P.doSomething() //Shows 'Parent' twice
    call A.doSomething() //Shows 'Child A' twice
    call B.doSomething() //Shows 'Child B' twice
endfunction


But it still raise an error
Code:
Unexpected: " xx takes nothing returns nothing"
What's wrong with stub methods, or how can I use them (because I realy need to overwrite parent methods). Thanks for any advices.
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Try :
JASS:
struct Big
    stub method test takes nothing returns nothing
        call BJDebugMsg("Big")
    endmethod
endstruct

struct Small extends Big
    method test takes nothing returns nothing
        call BJDebugMsg("Small")
    endmethod
endstruct

function gg takes nothing returns nothing
    local Big a = Big.create()
    local Small b = Small.create()

    call a.test() //Shows Big
    call b.test() //Shows Small
endfunction
 

Kajik

New Member
Reaction score
4
Try :
JASS:

struct Big
    stub method test takes nothing returns nothing
        call BJDebugMsg("Big")
    endmethod
endstruct

struct Small extends Big
    method test takes nothing returns nothing
        call BJDebugMsg("Small")
    endmethod
endstruct

function gg takes nothing returns nothing
    local Big a = Big.create()
    local Small b = Small.create()

    call a.test() //Shows Big
    call b.test() //Shows Small
endfunction
Exactly the same error (with "test" method)...
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
0.9.E.0.. hmm, it is a very old version of jasshelper.
Try the newest version, 0.A.2.B.
Since wc3c.net is downed, try to download from here instead.

Instruction :
After extracting the rar file, copy all extracted files into your jasshelper folder in NewGen.
A window will pop up which prompts you whether you want to replace the file or not, press replace button to continue.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top