|
Boost : |
From: Itay Maman (itay_maman_at_[hidden])
Date: 2002-07-02 01:36:40
Joel de Guzman wrote:
> Itay Maman wrote
>
>>
>> The Inheritance relationship is also a composition.
>
>
> ? care to explain ? I always thought that inheritance (*is-a*)
> is different from aggregation (*has-a*).
>
> Regards,
> --Joel
>
>
>
When you define D to inherit from B, then, B becomes a semi-data member
of D. The only difference is
that you need to use the "::" operator to access it (rather than the "."
operator)
We can say that inheritacne is a compostion + some additional properties
(primarily: polymorphism). As explained by Sutter, These additional
properties incur increased coupling which is a negative side-effect of
inheritance.
struct B
{
int x_;
} //
struct D1 : B
{
void fff()
{
cout << B::x_;
}
};
struct D2
{
B b_;
void fff()
{
cout << b_.x_;
}
};
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk