Afficher un message
Vieux 07/12/2007, 17h55   #13
Kira Yamato
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Am I the only one mad here?

On 2007-12-07 09:27:05 -0500, "Victor Bazarov" <v.Abazarov@comAcast.net> said:

> Kira Yamato wrote:
>> [..] I was looking for a convincing reason why overriding
>> was introduced in C++.

>
> Overriding was introduced as part of implementation of run-time
> polymorphism in the language. Without overriding it would be
> useless to declare functions virtual. If they don't override,
> how would the derived class provide its own behaviour for the
> declared virtual function in the class it inherits?
>
> Or did you mean you were looking for a convincing reason why
> _name hiding_ was introduced in C++?


Yes, I meant hiding. I was always under the same impression as the OP
that hiding surprises the programmers. Afterall, [public] inheritance
means derived classes should see "everything" [ok, non-private stuff]
from base class. However, hiding took away this for overloaded
functions.

And I couldn't find any FAQ online which had given a good explanation
why. That is until now...

--

-kira

  Réponse avec citation
 
Page generated in 0,04865 seconds with 9 queries