| 08-30-2007, 04:11 PM | #1 |
since im noob with vjass, i wanna know if its possible to declare methods with interface, and these methods will be automatically implemented into the structs that extends it. This way i wont need to redeclare the same methods for every struct tat extends the interface |
| 08-30-2007, 07:14 PM | #2 |
No, unfortuantly vJass doesn't support full blown inheritance. You can declare method stubs using the defualt parameter. i.e. JASS:method myMethod takes nothing returns nothing defaults nothing Alternatively you can use a text macro JASS://! textmacro MyMethod method myMethod codeHere takes nothing returns nothing //CODE HERE endmethod //! endtextmacro JASS:
//! runtextmacro MyMethod
You could aternatively make a function handle this if its not handling private variables. JASS:function myMethod takes interface m returns nothing |
| 08-31-2007, 12:33 AM | #3 |
hm i dont want functions, cus i want methods, which sounds more logical with objects. But i think i know wat to do now |
| 08-31-2007, 02:29 AM | #4 | |
Quote:
Since I made a whole map that was based in doing hundreds of virtual calls every 0.025 seconds I would say it is no that expensive. --- I need two things: - An example in which this is necessary - good syntax that could be added to interface so that "defaults" implemented code |
| 08-31-2007, 02:57 PM | #5 |
Well, Vex. I actually decided against using an abstract class and decided to go crazy and abstract things that would be a needed for each different type of hero object (I.e. one who can use a bag, one who can use an attributer,one who can use pshop) and instead make each one of them plug-inable state objects. Now I just need nice function delegates and the whole shebang could really be complete. I guess I should try to make each itemMenu object in a linked list so you don't need them to be in an explicit order. (so that way you can start using state 900 or something if your so daring and avoid danger, it would make finding state objects a bit more expensive but I seriously doubt your running through that many.) But seriously why can't you just have classes that all use the same internal arrays, but every single time you want to use something that may not be in a instance force a call like if (typeid==classThatHasThatMember)then I doubt that would be too expensive |
| 08-31-2007, 03:37 PM | #6 | |
Quote:
this is good when u have made something, example Object, and this object have some methods, like jumping, creating, moving. and i wanna make a struct called Actor that extends this with all the methods not needed to redeclare. This way i can add more stuffs into the actor struct faster and easier. and the users can also declare their type extends from my object when using the system. example creating struct called Bullet, Grenade ect... And the syntax hmm... i think u should be able to declare it inside the interface tag, like in struct, and all structs tat extends it will automatically use this |
