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?
You basically want to enforce type constraints requiring mapping and iter in your function. I'm pretty sure this is impossible. Yet another reason that Sepplesox
Name:
Anonymous2008-11-27 8:09
The Pleasure of Being Cummed Inside
Name:
Anonymous2008-11-27 8:40
void f(mapping& m, iter& i) { /* SEPPLES */ }
Ha ha only serious
Name:
Anonymous2008-11-27 10:08
>>13
Just look at the STL map headers, they've got it figured out without virtual functions. Otherwise you'll have to give me the code because I can't make shit out from your description.
Name:
Anonymous2008-11-27 10:13
The Pleasure of Being Cummed Inside
WE ARE NUMBER ONE!! FIRST RESULT!!! WE HAVE WON!!!
WE ARE NUMBER ONE!! FIRST RESULT!!! WE HAVE WON!!!
WE ARE NUMBER ONE!! FIRST RESULT!!! WE HAVE WON!!!
The Pleasure of Being Cummed Inside
Name:
Anonymous2008-11-27 23:45
>>18
Incorrect. /jp/ is number one. But I guess /jp/ and /prog/ are indistinguishable now, so what does it matter?
>>1
It sounds like that "concepts" from C++0x could solve this--but you'd have to wait a few years to use them.
Short answer: anything that is a "mapping" should be iterable, so suck it up and write the code to iterate through a binary tree. Or, at least, make the bintable implement iteration in a way that doesn't actually iterate, so that nothing happens.
>>24
He can do it without concepts.
Concepts are to templates as pure virtual classes (or interfaces) are to ordinary classes. Without them you just assume a type implements an interface without the interface being actually specified anywhere. (You get a few pages of template errors if it doesn't)
Name:
Anonymous2008-11-28 8:12
public <T extends Mapping && T extends Iter>
void iterateMap(T iterableMap) {
...
}
Name:
262008-11-28 8:13
Or you can do it like >>25 if he didn't fail BBCode miserably.
Name:
Anonymous2008-11-28 18:05
>>25
Here's a nickel kid, get yourself the fuck on