On 21 Jun 2006 16:37:25 -0700,
jq********@gmail.com wrote:
Belebele wrote: jq********@gmail.com wrote: > why don't the std classes have virtual destructors?
> doesn't it make sense to want to inherit from these classes and
> add/change functionality?
It is usually not a good idea to derive from concrete classes because
of the partial assignment problem and mixed-type assignment problem. It
also shows the need for new potential abstractions in your design.
Check out item 33 on Scott Meyers' More Effective C++. He explains it
all clearly. (That's a book that we should all keep handy).
"Object Oriented Design Heuristics" also mentions the problem and its
implications.
I guess my question is... why are the std classes concrete classes?
Some are. The C++ Standard library consists of 3 larger libraries
which have been introduced successively in the last 20 or so years.
Each of those libraries follows a different 'paradigm':
1. The C-Standard part is a procedural library
2. iostreams are designed according to the OO paradigm
3. the standardized subset of STL obeys to the generic and
value-semantics (which are not the same) dogma.
What confuses most beginners and many experts is the mix of C++ styles
that is presented in books, articles and newsgroups without any
further discussion of the underlying 'paradigms'.
Of course, there could be Java-like containers in C++ (they would
certainly be prefered to STL containers by many real-world
programmers). Also, the procedural stdio is more usable for many cases
than the OO experiment called iostreams. Alas, fundamental design
questions simply are not conducted in C++. Hence the permanent
confusion.
Best wishes,
Roland Pibinger