* Greg:
Alf P. Steinbach wrote: * Niks: i just wanted to know that is there any method to not allow any class
to inherit a specified class.
i.e. i hjave created a class and i dont want that anyone should inherit
it.
Usually (for beginners, at least) that indicates a flawed design.
What exactly indicates a flawed design and where?
A sealed C++ class (exluding C++ classes that are effectively sealed as a
consequence of e.g. pimpl idiom) generally says that it's so badly designed
that it's practically hopeless to derive from it and do that correctly, no
matter how much care is exercised: this class is sealed, because there's
absolutely no way to do anything reasonable with a derived class.
There are of course some exceptions.
But this is very much language dependent. C++ is built on the philosophy that
The Programmer Is Always Right, and should be allowed to do whatever, at his
or her own risk. It's not a beginner's language. In beginner's languages,
such as Java and C#, sealed classes are the norm. It's the opposite
philosophy, of the programmer being Mostly Wrong and needing stern guidance
and absolute limits (of course that applies to beginners... ;-)), and mostly
that means the programmer is meant to combine canned components, and should
not be extending or, Bush forbid, modifying their functionality.
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?