Viikuna
No Marlo no game.
- Reaction score
- 265
This works. It prints "A"
This too works. It prints "A", "B" and "C"
But this one does not. it says: Member already in use by a parent type.
So, how should I actually use interface variables with structs which extend eachother? Should I just use methods because they seem to be working, or is there some other way?
JASS:
scope noob initializer Init
interface face
string lol
endinterface
struct A extends face
string lol = "A"
endstruct
function Actions takes nothing returns nothing
local A a=A.create()
call BJDebugMsg(a.lol)
call a.destroy()
endfunction
This too works. It prints "A", "B" and "C"
JASS:
scope noob2 initializer Init
private interface face
method lol takes nothing returns nothing defaults nothing
endinterface
private struct A extends face
method lol takes nothing returns nothing
call BJDebugMsg("A")
endmethod
endstruct
private struct B extends A
method lol takes nothing returns nothing
call BJDebugMsg("B")
endmethod
endstruct
private struct C extends B
method lol takes nothing returns nothing
call BJDebugMsg("C")
endmethod
endstruct
private function Actions takes nothing returns nothing
local A a=A.create()
local B b=B.create()
local C c=C.create()
call a.lol()
call b.lol()
call c.lol()
call a.destroy()
call b.destroy()
call c.destroy()
endfunction
endscope
But this one does not. it says: Member already in use by a parent type.
JASS:
scope noob3 initializer Init
private interface face
string lol
endinterface
private struct A extends face
string lol = "A"
endstruct
private struct B extends A
string lol = "B" // I cant redeclare lol here
endstruct
private struct C extends B
string lol = "C"
endstruct
private function Actions takes nothing returns nothing
local A a=A.create()
local B b=B.create()
local C c=C.create()
call BJDebugMsg(a.lol)
call BJDebugMsg(b.lol)
call BJDebugMsg(c.lol)
call a.destroy()
call b.destroy()
call c.destroy()
endfunction
endscope
So, how should I actually use interface variables with structs which extend eachother? Should I just use methods because they seem to be working, or is there some other way?