随笔分类 -  Code Scrolls

摘要:多态是面向对象的核心特性。一说ADA即使95也没有很好地支持多态性。这可能并不是其一个显著缺陷,而是设计者认为多态性不一定能在ADA语言的通常应用模式中能很好地发挥。但毕竟多态性是很重要的一种属性。好在2005版本做了一些改进,其关键是引入了class-wide类型,即在基类上调'Class记号(Attribute)产生的类型。由于ADA主张常用静态的对象,所以这种情形下的多态看上去有点奇怪;另一方面多态往往和指针引用有很大关系,ADA的指针对对象和指针的声明和类型指定都很严格,所以用起来不像其他语言那么方便灵活。以下示例基本演示这个特性,并一些其他的语言特性和编程要点:1. 首先是定 阅读全文
posted @ 2011-11-15 21:33 quanben 阅读(493) 评论(0) 推荐(0)
摘要:以下是ADA实现的质因数分解程序,其等价C#程序可见:http://topic.csdn.net/u/20111112/18/2bf17a93-862d-458e-91d7-8682dc899315.html(由于没有专门的ADA代码显示模板,只能选择最相近的Delphi模板,故关键字标识会不正常)首先是功能单元模块(package)的声明文件(prime-factors-resolver.ads):with Ada.Containers.Doubly_Linked_Lists; use Ada.Containers; package prime_factors_resolver is ... 阅读全文
posted @ 2011-11-13 16:11 quanben 阅读(532) 评论(0) 推荐(0)
摘要:The description of the question: Locate the consecutive sub-list in a list that has the highest sum of values.For example:Given a list: (-1, 4, -2, 3, 1, 2, -2), the sub-list to return should be (4, -2, 3, 1, 2) with sum of values being 8.First thought of the question:The solution is expected to be 阅读全文
posted @ 2011-06-05 19:56 quanben 阅读(139) 评论(0) 推荐(0)
摘要:Interaction between target device and PC through RS-232 serial port is proved to be very useful in test process automation. Therefore, the effectiveness and accuracy of the communication along with the design of the protocol is crucial to the success of the testing system. Although a lot of issues r 阅读全文
posted @ 2009-10-15 01:38 quanben 阅读(197) 评论(0) 推荐(0)
摘要:C# type rebinding,a program demonstrating what I can figure out about simulatinggeneric type rebinding in C# (which is so common in C++ programs), it may lookstupid, but it really works as intended.using System;class BaseG{ public class ReboundType<_T> { public virtual _T T {get; set;} ... 阅读全文
posted @ 2009-04-11 20:58 quanben 阅读(157) 评论(0) 推荐(0)
摘要:/*..Onesolutiontothereleasing-requestproblem*///thisisa'non-releasing'routinerequestingreleasing routine_a(){mutex_lock(mutex); // ...mutex_lock(mutex_r); flag=1;request();// notify the releasorcond_wait(cond_r,mutex_r);flag=0; mutex_unlock(mutex_r); // ...mutex_unlock(mutex);}//thisisthe 阅读全文
posted @ 2008-12-15 11:41 quanben 阅读(181) 评论(0) 推荐(0)