|
![](/i/fill.gif) |
Le 13/08/2012 19:26, Warp nous fit lire :
> Orchid Win7 v1 <voi### [at] dev null> wrote:
>>> I have never quite understood the reason why C++ and Eiffel seem to be
>>> the only programming languages in existence that support multiple
>>> inheritance, while the rest of OO languages only support a highly
>>> crippled version of it.
>
>> I have to admit, Eiffel /does/ make the solution look very, very
>> complicated. (I can't actually remember off-hand how the heck C++ does
>> it...)
>
> Does what?
Manage inheritances, including multiple inheritances.
>
>> I would have thought the indirect code jump is probably far more
>> expensive than the space overhead.
>
> The additional space consumption is significant if you have eg. a class
> that would otherwise be the size of a pointer (and you need to instantiate
> millions of them). If you had forced virtual functions, it would double in
> size.
IIRC, C++ does not duplicates the class function members (not even
pointers to them) in each instance. Only the actual class (as 1 pointer)
is stored within each instance. The virtual function is just an index.
The first virtual/inheritance cost a pointer in the class. The next are
free.(in fact, with RTTI, even without inheritance, you might already
have that pointer: so no additional cost)
Post a reply to this message
|
![](/i/fill.gif) |