Afficher un message
Vieux 08/12/2007, 05h14   #4
Alf P. Steinbach
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Inheritance guidelines.

* Juha Nieminen:
> [About circles and ellipses]
> The answer is that neither should be inherited from the other. This is
> because a circle and an ellipse are at the *same* conceptual level.


Generally, when that's the case, the person's concepts are flawed :-).

E.g., a constant circle Is-A constant ellipse (the general relationship
is a bit more complicated).

In C++ this can be expressed via interfaces or via implicit conversion.


[snip]
> The correct solution is to create a more abstract concept which is
> common to both circles and ellipses (and other similar drawing
> primitives), for example a "DrawingPrimitive" class, and inherit
> "Circle" and "Ellipse" from it.


Sorry, but there's no general "the" correct solution.


Cheers, & hth.,

- Alf

--
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?
  Réponse avec citation
 
Page generated in 0,19996 seconds with 9 queries