码迷,mamicode.com
首页 > 其他好文 > 详细

Abstract Data Types in C

时间:2019-01-28 14:10:07      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:rem   interface   declare   abstract   operation   not   struct   ali   enc   

  • Interface declares operations, not data structure
  • Implementation is hidden from client (encapsulation)
  • Use features of programming language to ensure encapsulation

Common practice

  • Allocation and deallocation of data structure handled by module
  • Names of functions and variables begin with <modulename>_
  • Provide as much generality/flexibility in interface as possible
  • Use void pointers to allow polymorphism

#ifndef ARRAY_H

#define ARRAY_H

typedef struct Array *Array_T;

extern Array_T Array_new(void);

extern void Array_free(Array_T array);

extern void Array_insert(Array_T array, void *datap);

extern void Array_remove(Array_T array, void *datap);

Abstract Data Types in C

标签:rem   interface   declare   abstract   operation   not   struct   ali   enc   

原文地址:https://www.cnblogs.com/zjbfvfv/p/10329400.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!