"Type" is a set of actions, and "abstract data type" is a set of operations that have some kind of implementation. When we identify objects in the domain of a problem, the first question is "what can be done with this object" rather than "how this object is implemented". Therefore, if the natural description of a problem involves employees, contracts, and payroll records, the programming language used to solve the problem should include the employee, contract, and Payrollrecord types. This allows for a two-way, efficient conversion between the problem area and the solution area, and software written in this way can avoid "conversion noise" as much as possible to achieve simplicity and accuracy.
In a general-purpose programming language such as C + +, there is no application-specific type like employee, and we have something better: C + + facilitates the creation of complex, abstract data types. Essentially, the purpose of an abstract data type is to extend the programming language to a specific problem area.
There is no accepted solution for abstract data type design in C + +, and programming still requires inspiration and artistry, but many successful approaches follow this set of similar steps:
Select a descriptive name for the type. If it's difficult to name this type, it means you don't know what you want to achieve, you need to use more brains. An abstract data type should represent a simple, well-defined concept, and the name taken for that concept should be obvious.
Lists the actions that can be performed by the type. The basis for defining an abstract data type is what you can do with it. Do not forget to initialize (constructor), clean (destructor), copy (copy operation), and transform (single parameter constructors and conversion operators without explicit keyword modification). To avoid simply providing a string of get/set operations to a data member at implementation, it is not a data abstraction, but a lazy and unimaginative expression.
Design an interface for the type. As Scott Meyers tells us, a type should be "easy to use, hard to use incorrectly." Since the abstract data type is an extension of the language, it is important to design the language correctly. You want to put yourself in your shoes for the type of user and write some code that uses the type interface. Good interface Design In addition to considering the power of technology, psychological and emotional issues need to be considered.
The implementation type. Do not allow an interface that implements an impact type. The conventions that are committed to implement the interfaces of the type. Remember, in most cases, changes to the implementation of an abstract data type are far more frequent than changes to its interface.