JustSomeGuy said:
Victor Bazarov wrote:
Ok perhaps this is just a question of symantics then overridding vs hinding...
Semantics is integral part of any language. English or C++. It is
important to understand the difference even if only to ignore it.
Ok what functions do I 'need' to write?
How should *I* know? You're going to be using the class, not I.
I think that is the original
question.
But who except you can answer this?
If you want your class to be used by standard algorithms for searching,
sorting, etc., you need to provide iterators to the contents of your
collection. I strongly recommend a good book on the standard library
(Nicolai Josuttis wrote the best so far). The margins of this posting
are not wide enough to accommodate a decent explanation on how to write
your own library-compliant container.
Yes they are very big objects on average the list grows to 40 Mega-Bytes.
I believe you.
Are you saying that no one will be able to treat my class as a stl sdt::list?
What do you mean by "treat" your class as std::list? You cannot pass
a pointer or a reference to your class to another function that expects
a pointer or a reference to std::list, and have that other function call
member functions of _your_ class. If the functions are not virtual (and
they are not in std::list), they are not going to be resolved to your
"variations".
OTOH, if the other function is expecting _your_ list (either as a pointer
or as a reference, don't try passing it by value), then everything should
be fine.
In general you should remember that if you want the rest of the world to
be able to think that your class is just like std::list, your class must
have "is-a" relationship with std::list. However, if you want some of
std::list behaviour substituted for your own in certain conditions, you
need polymorphism, and none of standard containers provide that. That's
why I said that you'd be better off reimplementing everything you need
while deriving from std::list privately. At least then you will be able
to prevent people from passing your wonderful class into functions that
expect std::list (private inheritance disables implicit conversion to
base).
I apprieate the warning...
You're welcome.