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 阅读(273) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航:
 
<2006年2月>
2930311234
567891011
12131415161718
19202122232425
2627281234
567891011

导航

统计

常用链接

留言簿(4)

随笔档案

文章分类

文章档案

新闻档案

configuration

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜