// Calls base class implementation!
cir.Draw();
Console.ReadLine();
}
Figure 6-10.
Hmm . . . something is not quite right.
Clearly, this is not a very intelligent design for the current hierarchy. To force each child class to
override the Draw() method, you can define Draw() as an abstract method of the Shape class, which
by definition means you provide no default implementation whatsoever. To mark a method as
abstract in C#, you use the abstract keyword. Notice that abstract members do not provide any
implementation whatsoever:
C H A P T E R 6
■
U N D E R S TA N D I N G I N H E R I TA N C E A N D P O LY M O R P H I S M
206
8849CH06.qxd 10/1/07 10:35 AM Page 206
Do'stlaringiz bilan baham: |