// Update the Employee class as abstract
// to prevent direct instantiation.
abstract partial class Employee
{
...
}
With this, if you now attempt to create an instance of the Employee class, you are issued a
compile-time error:
// Error! Cannot create an abstract class!
Employee X = new Employee();
At this point you have constructed a fairly interesting employee hierarchy. We will add a bit
more functionality to this application later in this chapter when examining C# casting rules. Until
then, Figure 6-8 illustrates the core design of our current types.
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
203
8849CH06.qxd 10/1/07 10:35 AM Page 203
Do'stlaringiz bilan baham: |