Name: Anonymous 2008-11-27 6:01
I am aware that there are a lot of better languages, thank you.
Imagine this: I want to make class -- a mapping, just like an array, but indexes are strings, not numbers.
I make a mapping class with virtual set and get functions, and then create two classes - hashtable and bintree, inheriting them from mapping. I also want to iterate through all elements of hashtable (but not bintree - just because I don't need it and don't want to write the code). I create another class iter with two virtual functions - first and next (or whatever), and inherit hashtable from both mapping and iter.
Now, I can have a function that accepts mapping - and I can send it my hashtables and bintrees. I want to write a function that accepts an object that is both mapping and iter (it's hashtable, but I want it to accept all objects inherited from mapping and iter, not just this particular hashtable class). What type should I use?
The only answer I can come up with is to use another class - iter_mapping inherited from there two, but this looks plain stupid. What if I have more than two of these classes? 8, for example? Do I have to create a new dummy class for each combination?
Imagine this: I want to make class -- a mapping, just like an array, but indexes are strings, not numbers.
I make a mapping class with virtual set and get functions, and then create two classes - hashtable and bintree, inheriting them from mapping. I also want to iterate through all elements of hashtable (but not bintree - just because I don't need it and don't want to write the code). I create another class iter with two virtual functions - first and next (or whatever), and inherit hashtable from both mapping and iter.
Now, I can have a function that accepts mapping - and I can send it my hashtables and bintrees. I want to write a function that accepts an object that is both mapping and iter (it's hashtable, but I want it to accept all objects inherited from mapping and iter, not just this particular hashtable class). What type should I use?
The only answer I can come up with is to use another class - iter_mapping inherited from there two, but this looks plain stupid. What if I have more than two of these classes? 8, for example? Do I have to create a new dummy class for each combination?