ADT is the set of operations. ADT's are mathematical abstractions.
Does this mean that ADT are same as classes or am i confusing both together ?
As an example, a Stack ADT defines the basic stack operations like push and pop (but says nothing of how these operations should be implemented), while a Stack class would use either a linked-list or an array to actually implement these operations.
What is the difference between an ADT and a class in C++? In an ADT, the user does not have access to the implementation details. applies to the entire file. If you have a class defined in separate files, and change the way a class is defined, which files need to be re-compiled?
Explanation: Since classes use the concept of data abstraction therefore they are known as Abstract data types (ADT).
When a class is used as a type, it is an abstract type that refers to a hidden representation. In this model, an ADT is typically implemented as a class, and each instance of the ADT is usually an object of that class.
The key to the difference is abstract. Think of an ADT more like an interface - a class with only method declarations, no implementation details.
As an example, a Stack ADT defines the basic stack operations like push and pop (but says nothing of how these operations should be implemented), while a Stack class would use either a linked-list or an array to actually implement these operations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With