Download ABSTRACT DATA TYPES

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Abstract Data types
There are different ways to organize the data. High level language provides certain
structures which organize a collection of data elements with a particular set of accessing
functions. It is very important to choose the right data structure for a specific problem.
The choice basically depends upon program requirements. In C++ abstract data types
implemented as classes. As classes implements the concept of abstraction the class type
data i.e. the object is known as abstract data type.
Abstraction is the process of extracting the relevant properties of an object while ignoring
non-essential details. In other words we can say that abstraction focuses upon the
essential characteristics of an object relative to the perspective of the viewer. A class
represents essential features without including the background details or explanations.
They encapsulate all essential properties of the objects that are to be created. An abstract
data type is a data type defined in terms of operations that can be performed on data, not
in terms of structure of the data. Means an abstract data type encapsulates the data from
the complex details and explanations of how and where the data will be stored. Abstract
data types provide an interface for programming without knowing the complexity of how
the object actually performs its task. It makes object look like just another data type and
define in terms of operation, not in terms of structure.
Properties:  It provides an interface without exposing the implementation details.
 It exports a type with set of operations.
 It defines the application domain of the data type for the data.
 It defines attributes and methods which implements operation.
 It provides the unique mechanism to access data structure of the data types.
Example: The program of basic mathematical operations like Addition, Multiplication, and
Subtraction etc will be: #include<iostream.h>
#include<conio.h>
class Maths{
private:
int i, j;
public:
void Addition(int a, int b){
i=a;
j=b;
return i+j;
}
void Subtraction(int a, int b){
i=a;
j=b;
return i-j;
}
void Multiplication(int a, int b){
i=a;
i=b;
return i*j;
}
}
void main(){
clrscr();
Maths m;
int result;
result =m.Addition(10, 30);
cout<<result;
result =m.Multiplication(5,40);
cout<<result;
result =m.Subtraction(50,40);
cout<<result;
getch();
}
In the above program we defined two private variables. The main method only contains
the object of class Maths that implements abstraction on the inputs. It didn’t know how
the data is stored in that private variables, how the computation will be done. It only
means with the result that is defined in its own. In this manner the class containing the
private variables will act as a abstract data type in this program.
Related documents