new syntax for associative array
| kanesoban (37) | |||
| Helo, here is the thing: i made an implementation of the associative array in C++. It works well, but i want to make it's syntax closer to that of the original array's. Lets say, that Set(<Key>,<Value>) sets <Value> to <Key>, and that Value(<Key>) gives back the Value, that is associated with <Key>. What i want to do is being able to write array[<Key>] = <Value>; instead of array.Set(<Key>,<Value>) and <Value> = array[<Key>]; instead of <Value> = array.Value(<Key>) I thought about using define to define a macro that does this, but macros only work in the same file where they are. The Associative array is however in a header file, wich needs to be included where it is used. | |||
| Bazzy (539) | |||
Implement an operator:
(I'm assuming that you are using a class) | |||
| kanesoban (37) | |||
| Wow, it really works. I never tought that you can do this with operators. Thanks. Everyday i learn something new. | |||
This topic is archived - New replies not allowed.
