假設我有代碼段如下:(澄清目的/未很好地形成)C# - CLR如何在繼承期間組織內存/引用?
class Employee
{
#region fields
protected string _empID;
protected string _empName;
protected readonly string _ssn;
#endregion
public Employee(){}
public Employee(string _empID,string _empName,string _ssn)
{
this._empID =_empID;
this._empName=_empName;
this._ssn = _ssn;
}
}
class Manager : Employee
{
private string _branchID;
public Manager(int _branchID):base(string _empID,string _empName,string _ssn)
{
this._branchID=_branchID;
}
}
static void Main()
{
Manager mgr = new Manager("1","sam","xxx","Branch1");
}
使用基關鍵字我調用父類的構造。
在這種情況下繼承是如何組織的?我有一些壞的假設如下:
的經理是從員工獲得,管理類充滿(EMPID,empName,SSN)
-----------------
Manager
-----------------
empID
empName
ssn
branchID
第1步:構造函數調用:基地( 「1」, 「SAM」, 「XXX」)
步驟2:基類(員工)構造填充日提交(EMPID,empName派生類,SSN)
步驟3:branchID由分配派生類的構造
.......
我的問題是
哇!感謝您的關心和花費您的時間來解釋細節。我真的很感激你。 – user160677 2009-09-06 16:50:41