Abstract/Final
BlitzMax Forums/BlitzMax Beginners Area/Abstract/Final
| ||
Question: In blitzmax help, i noticed the AbstractType and FinalType keywords. I tried using them and my program doesnt compile anymore. It says Syntax error in user defined type declaration so i guess its in the help file and isnt really implemented or was removed? this does not compile and i figured it would: Type AbstractType TTest Field X:Int End Type thanks |
| ||
Type Test abstract ... end type type Test final ... end type abstract can be used for method / function declaration as well (but then without any function body, just the declaration) see max2d driver for an implementation and "show of" on how to use its power. |
| ||
yeah you basically screwed up :-D It should beType TypeName Abstract or Type TypeName Final as Dreamora shows. I've used Abstract for a couple of types that don't really do anythig on their own, they need to be extended. But I haven't found a use for Final yet. |
| ||
The use of final is when you create a class that you want to be not-extendable. This could be for example because it has some strange cross relations that would break on extending (as an outside user of a module would not know of that) or just because you don't want the user to steal your work and create "wrapped" classes for it. Don't know if C++ knows of a similar mechanism, Eiffel does it for sure. |
| ||
Yes c++ does it as well |
| ||
oh you guys are right i messed up the from the example, dang dylsexia ;) |