| 04-15-2009, 05:30 PM | #1 |
Hello... I'm a bit confused right now... got two(...3) questions: 1. What I have is an interface and several structs extending that interface. What I want is a static member (string) for each struct that is an individual static member for each structtype but may still be called via (interfacevariable).(membername). Unfortunately if I declare "static string anyname" in the interface-definition "anyname" will contain the same value for every struct extending that interface. 2. I would like to ask for the value of said static-string-member from a variable containing the struct's type. Is there a way to use a syntax like: (structtype-variable).(membername), just like you would do if you knew the struct's name beforehand? 3. How do you pronounce "vJass"? I'm not sure if I'm doin' it right.... |
| 04-15-2009, 06:40 PM | #2 |
structtypes are integers. You can simply use them as array indexes and store the names of all struct types in an array. Alternatively, you could have a regular member instead of a static one and store the structtype's string there in each struct's create method. |
| 04-15-2009, 07:25 PM | #3 |
Thank you for the swift answer, I'm afraid I forgot to write that I wanted the member to be static for a reason: I want to read its value before the first instance is created and, if possible, without creating any instances at all (for that purpose). I'm using the instance's static member as an array now - like you said. I'm not entirely happy yet, because l need to use onInit now and I'd rather keep everything inside my structs for convenience... But thats just me - its a great idea, it works, and I can finally move on, thanks al lot! |
| 04-15-2009, 11:40 PM | #4 |
There is no way to do what you want other than storing the name in an array by typeid. That doesn't mean you need to break encapsulation, you could make the array a static member of the interface. |
