2 ms·
I think the presented design is broken in C++ example. Point should remain a structure (it would be even more efficient in a runtime) and a new object, say Brus
by T-zex 16y ago
I think the presented design is broken in C++ example. Point should remain a structure (it would be even more efficient in a runtime) and a new object, say Brush, should be responsible for drawing on some Canvas. Then you could see the benefits of OO like drawing on different types of Canvas with different Brushes using the same Points.
- loup-vaillant 16y agoYes, but the same could be done in C: just make several compilation units, one per Canvas (or put several canvas in the same files, if they are small enough). Now if you thought of using a Canvas without determining a which one before hand, then you need subtype polymorphism, a much more significant feature, of which I do see the benefits.