COSC 2436 - Programming Fundamentals III Data Structures
Bob Comer, Professor of Computer Studies
Example Programs
Chapters 3 and 4 - Abstract Data Types
In C++ a class or struct allows a programmer to create a new data type.
A data type consists of two parts:
Description Program This program implements a Point ADT using a struct.
It covers material through section 3.6 of the textbook.
client program file
Point_client.cpp struct header file
Point.h struct implementation file
Point.cpp
This program implements a Point ADT using a class.
It covers the material through section 4.3 of the textbook
and only provides a limited set of operations -
assign a new value to a Point, display a Point, and get the magnitude of a Point.
client program file
Point_client.cpp Class header file
Point.h Class implementation file
Point.cpp
This version of the Point class
covers material from Chapter 4 of the textbook.
Changes from previous version:
client program file
Point_client.cpp class header file
Point.h class implementation file
Point.cpp
This version of the Point class
covers material from Chapter 4 of the textbook.
Changes from previous version:
client program file
Point_client.cpp class header file
Point.h class implementation file
Point.cpp
This version of the Point class
covers material from Chapter 4 of the textbook.
Changes from previous version:
client program file
Point_client.cpp class header file
Point.h class implementation file
Point.cpp
It is the class programmer's responsibility to ensure
that the class member functions never give inconsistent results.
Part of this is ensuring that the class member functions
never try to process invalid information from the client programmer.
Here we implement an ADT for x-y points where x and y are non-negative.
That is, only points in the upper-right quadrant are allowed.
client program file
PosPoint_client.cpp class header file
PosPoint.h class implementation file
PosPoint.cpp
Return to Programming Fundamentals II Home Page
Copyright: © 2015 by the Austin Community College
Department of Computer Studies. All rights reserved.
Comments to: Bob Comer
Last updated: February 8, 2015