fbpx
维基百科

抽象类型

编程语言中,抽象类型是指名義型別系統英语Nominal type system中不能直接实例化的类型;而非抽象的类型,即可以实例化的类型,則被称为具体类型[1]

一个抽象类型可以不提供实现,或者不完整的实现。在一些语言中,没有实现的抽象类型被称为协议接口。在基于类编程以及面向对象程序设计中,抽象类型被实现为抽象类(也被称为抽象基类),而具体类型被实现为具体类。

示例(Java) 编辑

//By default, all methods in all classes are concrete, unless the abstract keyword is used. abstract class Demo {  // An abstract class may include abstract methods, which have no implementation.  abstract public int sum(int x, int y);  // An abstract class may also include concrete methods.  public int product(int x, int y) { return x*y; } } //By default, all methods in all interfaces are abstract, unless the default keyword is used. interface DemoInterface {  [abstract] int getLength(); //Abstract can be used here, though is completely useless    //The default keyword can be used in this context to specify a concrete method in an interface  default int product(int x, int y) {  return x * y;  } } 

参考文献 编辑

  1. ^ Mitchell, John C.; Plotkin, Gordon D.; Abstract Types Have Existential Type (页面存档备份,存于互联网档案馆), ACM Transactions on Programming Languages and Systems, Vol. 10, No. 3, July 1988, pp. 470–502

抽象类型, 在编程语言中, 是指名義型別系統, 英语, nominal, type, system, 中不能直接实例化的类型, 而非抽象的类型, 即可以实例化的类型, 則被称为具体类型, 一个可以不提供实现, 或者不完整的实现, 在一些语言中, 没有实现的被称为协议, 接口, 在基于类编程以及面向对象程序设计中, 被实现为抽象类, 也被称为抽象基类, 而具体类型被实现为具体类, 示例, java, 编辑, default, methods, classes, concrete, unless, abstract, . 在编程语言中 抽象类型是指名義型別系統 英语 Nominal type system 中不能直接实例化的类型 而非抽象的类型 即可以实例化的类型 則被称为具体类型 1 一个抽象类型可以不提供实现 或者不完整的实现 在一些语言中 没有实现的抽象类型被称为协议 接口 在基于类编程以及面向对象程序设计中 抽象类型被实现为抽象类 也被称为抽象基类 而具体类型被实现为具体类 示例 Java 编辑 By default all methods in all classes are concrete unless the abstract keyword is used abstract class Demo An abstract class may include abstract methods which have no implementation abstract public int sum int x int y An abstract class may also include concrete methods public int product int x int y return x y By default all methods in all interfaces are abstract unless the default keyword is used interface DemoInterface abstract int getLength Abstract can be used here though is completely useless The default keyword can be used in this context to specify a concrete method in an interface default int product int x int y return x y 参考文献 编辑 Mitchell John C Plotkin Gordon D Abstract Types Have Existential Type 页面存档备份 存于互联网档案馆 ACM Transactions on Programming Languages and Systems Vol 10 No 3 July 1988 pp 470 502 取自 https zh wikipedia org w index php title 抽象类型 amp oldid 72391285, 维基百科,wiki,书籍,书籍,图书馆,

文章

,阅读,下载,免费,免费下载,mp3,视频,mp4,3gp, jpg,jpeg,gif,png,图片,音乐,歌曲,电影,书籍,游戏,游戏。