email } class name (multi part data representation) function belonging to the new datatype variable (field) beloging to the new datatype 12th Computer Chapter - - Data Abstraction Let main() contains p1:=Person() statement creates the object. firstName := " Padmashri " setting a field called firstName with value Padmashri lastName :="Baskar" setting a field called lastName with value Baskar id :=" - - " setting a field called id value - - email:="compsci@gmail.com" setting a field called email with value compsci@gmail.com - - output of firstName : Padmashri The class (structure) construct defines the form for multi-part objects that represent a person. Its definition adds a new data type, in this case a type named Person. Once defined, we can create new variables (instances) of the type.
In this example Person is referred to as a class or a type, while p1 is referred to as an object or an instance. You can think of class Person as a cookie cutter, and p1 as a particular cookie. Using the cookie cutter you can make many cookies. Same way using class you can create many objects of that type.
So far, you've seen how a class defines a data abstraction by grouping related data items. A class is not just data, it has functions defined within it. We say such functions are subordinate to the class because their job is to do things with the data of the class, e.g., to modify or analyze the data of a Person object. Therefore we can define a class as bundled data and the functions that work on that data .
From All the above example and explanation one can conclude the beauty of data abstraction is that we can treat complex data in a very simple way. • Abstract Data type (ADT) is a type (or class) for objects whose behavior is defined by a set of value and a set of operations. • The definition of ADT only mentions what operations are to be performed but not how these operations will be implemented. • ADT does not specify how data will be organized in memory and what algorithms will be used for implementing the operations • Constructors are functions that build the abstract data type.
• Selectors are functions that retrieve information from the data type. • Concrete data types or structures (CDT's) are direct implementations of a relatively simple concept. • Abstract Data Types (ADT's) offer a high level view (and use) of a concept independent of its implementation. Points to remember: 12th Computer Chapter - - • A concrete data type is a data type whose representation is known and in abstract data type the representation of a data type is unknown • Pair is a compound structure which is made up of list or Tuple • List is constructed by placing expressions within square brackets separated by commas • The elements of a list can be accessed in two ways.
The first way is via multiple assignment and the second method is by the element selection operator • Bundling two values together into one can be considered as a pair • List does not allow to name the various parts of a multi-item object. Points to remember: