看板 C_Sharp 關於我們 聯絡資訊
不好意思小弟沒學過cs 希望這問題不要鞭太大力 已經定義了class Context 和 abstract class State public class ConcreteStateA : State { public ConcreteStateA(Context theContext):base(theContext) {} .... (略) .... 第一個冒號我知道是繼承 第二個冒號:base(theContext) 不是繼承吧? 這是做甚麼的???? 附上context 和 state的碼 using UnityEngine; using System.Collections; namespace DesignPattern_State { // 持有目前的狀態,並將有關的訊息傳給狀態 public class Context { State m_State = null; public void Request(int Value) { m_State.Handle(Value); } public void SetState(State theState ) { Debug.Log ("Context.SetState:" + theState); m_State = theState; } } // 負責封裝當Context處於特定狀態時所該展現的行為 public abstract class State { protected Context m_Context = null; public State(Context theContext) { m_Context = theContext; } public abstract void Handle(int Value); } .... (略) .... -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 101.138.93.70 ※ 文章網址: https://www.ptt.cc/bbs/C_Sharp/M.1468885902.A.DC7.html
kevintsengtw: MSDN C# 建構式 https://goo.gl/8mtj1T 07/19 09:13