AERYU

          ColdFusion中的繼承

          ColdFusion中的繼承體現在CFCs,用法就是在<cfcomponent>中加入屬性extends,簡單的說,sub.cfc通過繼承parent.cfc,就自動擁有了parent.cfc中的(constructor構造器中的)變量、屬性和公開的(public)方法,比如:

          <!--- parent.cfc --->
          <cfcomponent>
            <cffunction name="getSth">
              <cfreturn "this is parent class">
            </cffunction>
          </cfcomponent>

          <!--- sub.cfc --->
          <cfcomponent extends="parent">
            <cffunction name="getSthFromParent">
              <cfreturn super.getSth()>
            </cffunction>
          </cfcomponent>
          <!--- test.cfm --->
          <cfset Obj = createObject("component", "sub")>
          <cfset temp = Obj.getSthFromParent()>
          <cfoutput>#temp#</cfoutput>

          test.cfm將輸出:“this is  parent class”

          posted on 2006-02-22 08:52 AERYU 閱讀(292) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          <2006年2月>
          2930311234
          567891011
          12131415161718
          19202122232425
          2627281234
          567891011

          導航

          統計

          常用鏈接

          留言簿(4)

          隨筆檔案

          文章分類

          文章檔案

          新聞檔案

          configuration

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 四会市| 兴和县| 大理市| 安图县| 当涂县| 治多县| 资兴市| 肃宁县| 大理市| 进贤县| 自治县| 阿拉善左旗| 小金县| 明星| 东宁县| 竹溪县| 清新县| 鄱阳县| 临颍县| 开平市| 永春县| 新绛县| 通化市| 铜山县| 洛扎县| 博罗县| 邯郸县| 浏阳市| 卢氏县| 囊谦县| 芦溪县| 子洲县| 苏州市| 秭归县| 恭城| 任丘市| 桦南县| 青浦区| 井冈山市| 沙洋县| 长葛市|