AERYU

          2006年2月22日

          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 @ 2006-02-22 08:52 AERYU 閱讀(292) | 評論 (0)編輯 收藏

          <2006年2月>
          2930311234
          567891011
          12131415161718
          19202122232425
          2627281234
          567891011

          導航

          統計

          常用鏈接

          留言簿(4)

          隨筆檔案

          文章分類

          文章檔案

          新聞檔案

          configuration

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 河池市| 得荣县| 京山县| 德庆县| 登封市| 东乌珠穆沁旗| 越西县| 扎赉特旗| 油尖旺区| 金华市| 利川市| 南部县| 容城县| 香港| 义乌市| 岳阳县| 仙游县| 屯留县| 福贡县| 平乐县| 铜梁县| 虎林市| 安龙县| 南雄市| 秦皇岛市| 揭阳市| 大安市| 封开县| 满城县| 松潘县| 宁河县| 卢湾区| 丹寨县| 中西区| 霍州市| 呼伦贝尔市| 彝良县| 高陵县| 敦煌市| 威宁| 富宁县|