Q23. Define in brief about Abstract Data type (ADT).
Answer:
Abstract Data Type (ADT)
Abstract Data Type (ADT) is a data type that allows the programmer to use it without concentrating on the details of its implementation.
A class can be treated as an abstract data type by separating its specification from the implementation of its operations.
This separation between the specifications and the implementation can be obtained by,
(i) Considering and placing all the member variables in the private section of the class.
(ii) Placing all the needed operations in the public section and describing the ways of using these member functions.
(iii) Considering all the helping functions as private member functions and placing them in private section of the class.
Table: Class as an ADT
The interface of an ADT specifies | how to use it in our program and consists of the public member functions along with the accompanying comments that describes the way to use these public member-functions.
The implementation of an ADT specifies the way to realize an interface as a C++ code and consists of private members of a class and the definitions of both the private and public member functions.
To use an ADT in our program, the only thing we need to know is its interface, but not its implementation i.e., implementation is not required to write the main program.