"Dave" <be***********@yahoo.com> wrote in message
news:10*************@news.supernews.com...
Any thoughs on why a member subobject may be const but an inherited
subobject may not? i.e. the following is not possible:
class derived: public const base
{
...
};
but the following is:
class derived
{
...
const base b;
};
The only restriction for the second case is that constructors must
initialize base in its initializer list...
Of course, this also all applies to volatile as well...
Well, what would you want the first version for? The base class that is
inherited is not a "sub-object", it's a base class. You're declaring an
object at the time, and saying that class derived is derived from class
base. What would it mean to you to say that the class type it derives from
is const? A type is neither const nor non-const. An instance, however, can
be const, and that is what the member b is, a const instance of an object of
type base.
-Howard