Another Example
of Abstraction

2/16/99


Click here to start


Table of Contents

Another Example
of Abstraction

A problem

How might the interface look?

A note on interfaces

Buffer definition

Buffering conventions

Initialization

``Print'' a number

Empty the buffer

Implications

Emptying the buffer

Printing a row

The last page

Policy decisions

The object of the game

Allowing multiple buffers

Allowing multiple files

Memory management

Using a one-dimensional array

Indices

Interface definition

How will we implement it?

Expanded class definition

How might we use it?

Machine-checkable specifications

The Buffer constructor

Allocating memory with new

Other properties of new

``Printing'' a number

Flushing the buffer

Revising the class definition

Flushing the buffer

Printing a row

The destructor

What have we gained?

Not quite the whole truth...

References

Reference examples

Why bother with references?

A function that modifies its argument

Passing uncopyable arguments

Reference to const

Examples of references to const

Copy constructors

Additional pieces

Author: Andrew Koenig

Email: ark@research.att.com

Home Page: http://www.research.att.com/info/ark