Class Thing
Class Animal
Class Other -superclass {Animal Thing} Thing instproc init {args} {
puts "here is init from:thing"
eval $self next $args
}
Thing instproc move {} {
puts "here is move from:thing"
} Animal instproc init {args} {
puts "here is init from:animal"
eval $self next $args
}
Animal instproc move {} {
puts "here is move from:animal"
eval $self next
} Other instproc init {args} {
puts "here is init from:other"
eval $self next $args
}
Other instproc move {} {
puts "here is move from:other"
eval $self next
}
Other other
other move

输出:

here is init from:other
here is init from:animal
here is init from:thing
here is move from:other
here is move from:animal
here is move from:thing

上面是简单地继承两个父类,在调用next的时候,顺序是按继承时候的从左到右的顺序,依次调用。

如果是这样:

Class theOne
Class Thing -superclass theOne
Class Animal
Class Other -superclass {Thing Animal} theOne instproc init {args} {
puts "here is init from:theOne"
eval $self next $args
}
theOne instproc move {} {
puts "here is move from:theOne"
eval $self next
} Thing instproc init {args} {
puts "here is init from:thing"
eval $self next $args
}
Thing instproc move {} {
puts "here is move from:thing"
eval $self next
} Animal instproc init {args} {
puts "here is init from:animal"
eval $self next $args
}
Animal instproc move {} {
puts "here is move from:animal"
eval $self next
} Other instproc init {args} {
puts "here is init from:other"
eval $self next $args
}
Other instproc move {} {
puts "here is move from:other"
eval $self next
}
Other other
other move

输出:

here is init from:other
here is init from:thing
here is init from:theOne
here is init from:animal
here is move from:other
here is move from:thing
here is move from:theOne
here is move from:animal

OTCL的多继承的更多相关文章

  1. OTCL,面向对象的脚本一

    Otcl 简介 面向对象的脚本语言 类变量和类方法 Otcl的基类称为Object(类的名字,不是面向对象中的"对象"),所以的Otcl类都是从Object派送来的. 直接贴代码, ...

  2. javaScript的原型继承与多态性

    1.prototype 我们可以简单的把prototype看做是一个模版,新创建的自定义对象都是这个模版(prototype)的一个拷贝 (实际上不是拷贝而是链接,只不过这种链接是不可见,给人们的感觉 ...

  3. JavaScript的继承实现方式

    1.使用call或apply方法,将父对象的构造函数绑定在子对象上 function A(){ this.name = 'json'; } function B(){ A.call(this); } ...

  4. javascript中的继承与深度拷贝

    前言 本篇适合前端新人,下面开始...... 对于前端新手来说(比如博主),每当对js的对象做操作时,都是一种痛苦,原因就是在于对象的赋值是引用的传递,并非值的传递,虽然看上去后者赋值给了前者,他们就 ...

  5. 谈谈一些有趣的CSS题目(四)-- 从倒影说起,谈谈 CSS 继承 inherit

    开本系列,讨论一些有趣的 CSS 题目,抛开实用性而言,一些题目为了拓宽一下解决问题的思路,此外,涉及一些容易忽视的 CSS 细节. 解题不考虑兼容性,题目天马行空,想到什么说什么,如果解题中有你感觉 ...

  6. JS继承类相关试题

    题目一: //有关于原型继承的代码如下:function Person(name) {   this.name = name;}Person.prototype = {     getName : f ...

  7. JS继承之寄生类继承

    原型式继承 其原理就是借助原型,可以基于已有的对象创建新对象.节省了创建自定义类型这一步(虽然觉得这样没什么意义). 模型 function object(o){ function W(){ } W. ...

  8. JS继承之借用构造函数继承和组合继承

    根据少一点套路,多一点真诚这个原则,继续学习. 借用构造函数继承 在解决原型中包含引用类型值所带来问题的过程中,开发人员开始使用一种叫做借用构造函数(constructor stealing)的技术( ...

  9. JS继承之原型继承

     许多OO语言都支持两种继承方式:接口继承和实现继承.接口继承只继承方法签名,而实现继承则继承实际的方法.如前所述,由于函数没有签名,在ECMAScript中无法实现接口继承.ECMAScript只支 ...

随机推荐

  1. ASP.NET MVC 4.0 学习6-Model Binding

    一,ViewData,ViewBag與TempData ASP.NET MVC架構中,通過繼承在Controller中的ViewData,ViewBag和TempData和View頁面進行資料的存取, ...

  2. js区分移动设备与PC

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. 360云后台(使用HTTP Cache服务器)

    工作职责:设计优化HTTP Cache服务器,负载均衡服务器,调度系统等核心系统开发优化CDN系统架构满足流量.性能.成本要求 技能要求: 精通Linux, C/C++语言,HTTP协议精通高性能服务 ...

  4. C# 调用 Web Service

    Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求,轻量级的独立的通讯技术.是:通过SOAP ...

  5. Android高德地图开发具体解释

    这段时间开发的时候用到了高德地图,对高德地图开发有心得体会,如今分享给大家.对我开发过百度地图的我来说,整体来说高德地图Demo,没有百度解说的具体 个人更偏向于使用百度地图,可是没办发,项目须要使用 ...

  6. redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool

    超时 Exception in thread "main" redis.clients.jedis.exceptions.JedisConnectionException: jav ...

  7. 其中 (%{WORD:x_forword}|-) |表示或的意思

    121.40.205.143 [30/Aug/2016:14:03:08 +0800] "GET /resources/images/favicon.ico HTTP/1.1" - ...

  8. STL中map与hash_map容器的选择收藏

    这篇文章来自我今天碰到的一个问题,一个朋友问我使用map和hash_map的效率问题,虽然我也了解一些,但是我不敢直接告诉朋友,因为我怕我说错了,通过我查询一些帖子,我这里做一个总结!内容分别来自al ...

  9. View not attached to window manager crash 的解决办法

    View not attached to window manager crash 的解决办法 转自:http://stackoverflow.com/questions/22924825/view- ...

  10. Maximal Square 解答

    Question Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1' ...