An abstract data type (ADT) defines operations and their behavior without revealing the representation. A stack ADT offers push, pop, and peek; whether it uses an array or linked list is hidden. In C you build ADTs with a struct and a set of functions, ideally an opaque pointer declared in a header and defined in the .c file.
In a real project the struct would live in the .c file for true hiding.
Edge Cases & Pitfalls
Check these before relying on Abstract Data Types in real programs.
leak
Exposing fields
If callers touch struct fields, you cannot change the representation later.
own
Unclear ownership
Document who frees the object.
Remember
Key Takeaways
Operations first, representation hidden.
Opaque pointers enforce it.
Document ownership.
One line: An abstract data type (ADT) defines operations and their behavior without revealing the representation.
Frequently Asked Questions
A description of a data type by its operations and behavior, independent of how it is implemented.
Declare an opaque struct pointer and function prototypes in a header, then define the struct and functions in a source file.
Continue with "Choosing a Data Structure in C" next. Match common operations to the structure that makes them cheap. The C Data Structures hub lists every topic in order.