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

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 资中县| 文水县| 密山市| 仙游县| 乌鲁木齐县| 金堂县| 德令哈市| 宜丰县| 治县。| 巴楚县| 交城县| 鄂伦春自治旗| 安福县| 海阳市| 桂平市| 大悟县| 合肥市| 襄汾县| 延安市| 洛南县| 怀化市| 桐乡市| 民丰县| 新乡县| 方山县| 晋宁县| 海盐县| 开阳县| 宁晋县| 黄石市| 河西区| 赤水市| 宽甸| 沛县| 谷城县| 恩平市| 双桥区| 荥经县| 名山县| 遂溪县| 清丰县|