• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Struct Parents

Status
Not open for further replies.
Hello there.

Lets use the 3 ways of fast answering.

Step 1: The Situation.

JASS:
struct Parent
    boolean test
endstruct

struct Child extends Parent
    public method changeTest takes boolean bol returns nothing
    // ?? What goes in here
    endmethod
endstruct

Step 2: The Description
I have a parent and a chields struct. In the chields struct, I want to use the parents struct, without making it static.

Step 3: Your answer! :p
 
Level 11
Joined
Feb 22, 2006
Messages
752
It should work. I use stuff like that all over my map and I don't have any problems.

JASS:
struct A
    string s = ""
endstruct

struct B extends A
    method setString takes string s returns nothing
        set this.s = s
    endmethod
endstruct

function foo takes nothing returns nothing
    local B this = B.create()
    call this.setString("Hello world!")
    call BJDebugMsg(this.s)
endfunction

Function foo should display "Hello world!"

except for those methods marked with stub as overwriteable
Child structs inherit stub methods also; the only difference is that they may be overwritten.
 
Status
Not open for further replies.
Top