| 03-25-2007, 09:54 AM | #1 |
I'm new to this jass helper thing, I've been normal jassing for a long time, and I have some C++ background so it's really just an awesome merger of both languages O_o! Anyways, I'm having trouble with operator overloading. For some reason (I'm sticking as close to the example as I feel safe with) my overloading doesn't work. -Take a looksy: JASS:struct PointMath real x real y integer nu method PolarProjection takes real dist, real ang returns nothing set .nu = 1 set .x = .x + dist * Cos(ang) set .y = .y + dist * Sin(ang) endmethod method OffsetPoint takes real dx, real dy returns nothing set .nu = 1 set .x = .x + dx set .y = .y + dy endmethod method operator[] takes real dist, real ang returns real return PolarProjection(dist, ang) endmethod method operator[]= takes real dx, dy returns nothing return OffsetPoint(dx, dy) endfunction endstruct Compiling error: "Not a valid indentifier name!" (Shows for both marked lines) Thanks for the help. -Root. |
| 03-25-2007, 10:59 AM | #2 |
method operator[]= takes real dx, real dy returns nothing
Edit: oh, both lines... For the [] operator, it can only take one arguement I'm guessing, unless the syntax allows stuff like call BJDebugMsg(R2S(point[3,4])) Oh yeah, and polar projection doesn't return anything, but your [] operator needs to return a real. Mm. I don't know exactly what syntax limitations there are. |
| 03-25-2007, 12:50 PM | #3 |
Yes, [] should only get one argument and return something, but the correct syntax error would be that. Are you sure you are using the latest JassHelper? |
| 03-25-2007, 11:09 PM | #4 |
Dled it 4 days ago. -Even with corrected syntax it won't compile: Code:
method operator[] takes integer whocares returns real return 100. endmethod |
| 03-25-2007, 11:15 PM | #5 |
JASS:struct PointMath real x real y integer nu method PolarProjection takes real dist, real ang returns nothing set .nu = 1 set .x = .x + dist * Cos(ang) set .y = .y + dist * Sin(ang) endmethod method OffsetPoint takes real dx, real dy returns nothing set .nu = 1 set .x = .x + dx set .y = .y + dy endmethod method operator[] takes integer whocares returns real return 100. endmethod method operator[]= takes real dx, real dy returns nothing call .OffsetPoint(dx, dy) //notice the . endmethod endstruct Compiles correctly in jasshelper 0.9.7.1 downloading 4 days ago <- But from the jasshelper thread and not from newgen pack? |
| 03-25-2007, 11:37 PM | #6 |
I had the newgen version, I dled the single version from your sig and unzipped it in the folder, it still won't compile. -Edit I was apparantly under the impression that WEHelper and the jass new gen pack are connected somehow - Moved grimore into the correct place and it compiles now. Sorry -,- |
