作者Ommm5566 (56天团)
看板C_Sharp
标题[问题] function语法问题
时间Tue Jul 19 07:51:38 2016
不好意思小弟没学过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://webptt.com/cn.aspx?n=bbs/C_Sharp/M.1468885902.A.DC7.html