ADT-Remarks - CMPS 101 Algorithms and Abstract Data Types...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CMPS 101 Algorithms and Abstract Data Types Some Additional Remarks on ADTs and Modules in ANSI C Suppose you wish to implement an ADT in C. The particular ADT is unimportant, so let’s just call it a “Blah”. You should create the following files at minimum: Blah.c, Blah.h, BlahTest.c. Blah.c represents the ‘inside’ of the black box, Blah.h represents the interface, and BlahTest.c is a kind of dummy client module used to wring the bugs out of the Blah ADT. File Blah.h will contain prototypes for all exported functions which represent ADT operations. It will also contain the line. typedef struct Blah* BlahRef; This defines BlahRef to be a pointer to some struct called Blah . Blah.c will #include Blah.h, and will contain definitions of all exported functions, and perhaps definitions of some private functions and structs as well. Blah.c will also contain the following typedef statement. typedef struct Blah{ /* code which defines fields for the Blah ADT */ } Blah; A client module can then #include Blah.h giving it the ability to declare variables of type BlahRef, as well as functions which take BlahRef parameters. However, the client cannot dereference a BlahRef
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/03/2009 for the course CS CS101 taught by Professor Agoreback during the Spring '09 term at American College of Gastroenterology.

Page1 / 2

ADT-Remarks - CMPS 101 Algorithms and Abstract Data Types...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online