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 }
2、使用sealed 保证类不会被继承(密封类)