Abstract Classes

Recall our definition of the Shape class. One remark we made when defining its two virtual properties was the fact we had to provide default implementations that didn’t really have much meaning:

image

Although 0.0 might seem like a good default value, wouldn’t it be much better not to have to specify a value at all? Moreover, does it even mean to create an instance of the Shape object? Isn’t a shape something very abstract that needs to be concretized to help someone draw a mental picture? Although Square and Circle are very concrete, the concept of a Shape definitely isn’t. The following use of Shape looks weird for that very reason: ...

Get C# 4.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.