C#三大支柱之继承

1、使用base

若子类需要使用父类公开或受保护的成员则需要是base

 1 class Manager : Employee
 2     {
 3         public int StockOptions { get; set; }
 4 
 5         public Manager(string fullName, int age, int empID,
 6           float currPay, string ssn, int numbOfOpts)
 7             : base(fullName, age, empID, currPay, ssn)
 8         {
 9             // This field is defined by the Manager class.
10             StockOptions = numbOfOpts;
11         }
12         // Add back the default ctor
13         public Manager() {}
14     }
View Code

2、使用sealed 保证类不会被继承(密封类)

posted @ 2013-10-06 23:50  kelite  阅读(181)  评论(0编辑  收藏  举报