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. openssl 第一篇

    自从老罗赞助了openssl以及心脏出血事件的新闻,得以了解了openssl.那么什么是openssl呢?下面摘自官网: The OpenSSL Project is a collaborative  ...

  2. Python学习(六) Python数据类型:字典(重要)

    字典dict: 字典其实就相当于java里面的Map,用来存储键值对的.其中存储的数据时无序的. 假如有这样的数据: t1=['name','age','sex'] t2=['tom',30,'mal ...

  3. [XMPP]iOS聊天软件学习笔记[三]

    今天做了好友界面,其实xmpp内部已经写好很多扩展模块,所以使用起来还是很方便的 开发时间:五天(工作时间) 开发工具:xcode6 开发平台:iOS8 XMPP框架:XMPPFramework gi ...

  4. 分析java 嵌套类与内部类

    一.什么是嵌套类及内部类?     可以在一个类的内部定义另一个类,这种类称为嵌套类(nested classes),它有两种类型:静态嵌套类和非静态嵌套类.静态嵌套类使用很少,最重要的是非静态嵌套类 ...

  5. SQL Server 索引的图形界面操作 <第十二篇>

    一.索引的图形界面操作 SQL Server非常强大的就是图形界面操作.关于索引方面也一样那么强大,很多操作比如说重建索引啊,查看各种统计信息啊,都能够通过图形界面快速查看和操作,下面来看看SQL S ...

  6. java生成json字符串的方法

    例1:将map对象添加一次元素(包括字符串对.数组),转换成json对象一次. 代码: package com.json; //这是使用org.json的程序: import java.util.Ha ...

  7. 简单了解下Dubbo

    1. Dubbo是什么? Dubbo是一个分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案.简单的说,dubbo就是个服务框架,如果没有分布式的需求,其实是不需 ...

  8. IOS 打印网络请求全链接

    NSMutableString *urlStr = [NSMutableString stringWithFormat:@"%@?",request.URL]; ;i<[pa ...

  9. 水务新、老营收系统大PK

    今天想撩一下咱水务界的大拿——营业收费管理系统. 营业收费 随着城市供水规模的不断扩大及户表改造的深入以及阶梯水价的实行还有移动平台等第三方支付的蓬勃发展,原有的营收软件系统已经不能适应目前水司的管理 ...

  10. C#.Net前台线程与后台线程的区别

    本文来自:http://www.cnblogs.com/zfanlong1314/archive/2012/02/26/2390455.html .Net的公用语言运行时(Common Languag ...