📜  抽象数据类型和对象之间的区别

📅  最后修改于: 2021-09-28 09:46:35             🧑  作者: Mango

1.抽象数据类型(ADT)
抽象数据类型 (ADT)是数据类型的数学模型。我们可以将抽象数据类型视为一个黑匣子。由于黑盒隐藏了内部结构,ADT隐藏了数据类型的设计。可以从数据用户的角度指定抽象数据类型的行为(语义),特别是在潜在值、对此类数据的潜在操作以及这些操作的行为方面。它是用户定义的数据类型。
它是定义的概念抽象,表示数据和数据操作。抽象数据类型关注的是什么,而不是如何(它们被装饰性地表达,并且它们不指定算法或数据结构)。示例包括列表、堆栈、队列和集合。

2. 对象:
对象并不是实现抽象的唯一方法。正如许多人所知,它实现了过程数据抽象。抽象数据类型以不同的方式处理抽象。当我们定义一个类时,没有分配内存,但是当我们实例化(即创建一个对象)时,会分配内存。
一个对象是一个类的实例,拥有它自己的任何非静态变量的副本。

抽象数据类型和对象之间的区别:

Abstract Data Type

Objects

Abstract data type is abstraction that define set of values and set of operations on these values. It is a self-contained component which consists of methods and properties to make certain type of data useful.
User-defined data type. It is an instance of class.
ADT is made of with primitive datatypes. An object is an abstract data type with the addition of polymorphism and inheritance.
It is a type (or class) for objects whose behaviour is defined by a set of value and a set of operations. It is a basic unit of Object-Oriented Programming.
 Abstract datatype is not necessarily an OOP concept. Objects is an OOP concept.
Common examples include lists, stacks, sets, etc.

Objects have states and behaviours  

Test t = new Test();.

Allocate memory when data is stored. When we instantiate an object then memory is allocated.