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 閱讀(289) 評論(0)  編輯  收藏


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


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

          導航

          統計

          常用鏈接

          留言簿(4)

          隨筆檔案

          文章分類

          文章檔案

          新聞檔案

          configuration

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 彝良县| 邻水| 河间市| 柳江县| 綦江县| 灌云县| 黄大仙区| 天津市| 富顺县| 营口市| 乐昌市| 八宿县| 历史| 文水县| 阜新市| 依安县| 廊坊市| 乌鲁木齐县| 临沧市| 灵川县| 古丈县| 台中市| 周至县| 博兴县| 盘锦市| 丘北县| 枝江市| 睢宁县| 罗平县| 肇东市| 金堂县| 河东区| 横峰县| 富阳市| 茶陵县| 平谷区| 通榆县| 湖北省| 靖远县| 东丽区| 任丘市|