第二步 :構建對象
以下代碼實現了一個類Employee
//構建對象class Employee
{
private
string m_firstname;
private
string m_middlename;
private
string m_lastname;
private
string m_SSN;
//構造器,當實例化對象時對屬性成員賦值
public Employee( string FirstName,
string MiddleName,
string LastName,
string SSN )
{
m_firstname = FirstName;
m_middlename = MiddleName;
m_lastname = LastName;
m_SSN = SSN;
}
public
string FirstName
{
get
{
return m_firstname;
}
set
{
m_firstname = value;
}
}
public
string LastName
{
get
{
return m_lastname;
}
set
{
m_lastname = value;
}
}
public
string MiddleName
{
get
{
return m_middlename;
}
set
{
m_middlename = value;
}
}
public
string SSN
{
get
{
return m_SSN;
}
set
{
m_SSN = value;
}
}
}