Macmillan Computer Science Series: Professor F.H. Sumner, University of Manchester
Macmillan Computer Science Series: Professor F.H. Sumner, University of Manchester
Macmillan Computer Science Series: Professor F.H. Sumner, University of Manchester
continued overleaf
Other titles
Roy Anderson, Management, Information Systems tl1lll Computers
Ian 0. Angell and Dimitrios Tsoubelis, Advanced Graphics on VGA tl1lll XGA Cards Using
Borltlllll C++
B. V. Cordingley and D. Chamund, Advanced BASIC Scientific Subroutines
N. Frude, A Guide to SPSS/PC+, second edition
Percy Mett, Introduction to Computing
Tony Royce, COBOL- An Introduction
Tony Roryce, Structured COBOL- An Introduction
Barry Thomas, A PostScript Cookbook
C++ Object-Oriented
Programming
R. J. Mitchell
Department of Cybernetics
University of Reading
M
!50th YEAR
MACMILLAN
© R. J. Mitchell 1993
All rights reserved. No reproduction, copy or transmission of
this publication may be made without written permission.
No paragraph of this publication may be reproduced, copied or
transmitted save with written permission or in accordance with
the provision of the Copyright, Designs and Patents Act 1988,
or under the terms of any licence permitting limited copying
issued by the Copyright Licensing Agency, 90 Tottenham Court
Road, London W1P 9HE.
Any person who does any unauthorised act in relation to this
publication may be liable to criminal prosecution and civil
claims for damages.
A 3.5 in. DOS diskette containing the program source and answers
to the exercises is available at the price of £25.00 or $40.00 (inc.
postage/packing - airmail overseas).
Please send your personal cheque to: Globe Book Services Ltd,
Houndmills, Basingstoke, Hampshire, RD21 2XS, UK.
Access/Visa/American Express/Diners Club accepted. Please quote
number and expiry date.
Please quote ISBN 978-0-333-59862-7 (diskette) when ordering.
1 Introduction 1
1.1 Software development 2
1.2 Algorithms and data 3
1.3 Conventional approach to programming 3
1.4 Object-oriented approach 5
1.5 Inheritance 8
1.6 Strong· typing and overloading 11
1.7 Libraries 12
1.8 Abstraction 12
1.9 Programming style and documentation 13
2 Object-Oriented Design 16
2.1 Drawing package overview 16
2.2 Object-oriented design 18
2.3 Systems design 26
2.4 The drawing package 29
3 Simple Classes 36
3.1 The WithinWindow class - requirements 36
3.2 Classes 37
3.3 The WithinWindow class - implementation 38
3.4 The Difference class 39
3.5 Bezier curves: a class with multiple constructors 43
3.6 Ellipses 48
3.7 Circles 50
3.8 Transfonnation matrices 53
v
vi Contents
s More Inheritance 8S
5.1 Requirements in the drawing package 85
5.2 The graphical hierarchy in the drawing package 86
5.3 The member functions of the hierarchy 89
5.4 Edit function and virtual functions 92
5.5 Other member functions 94
5.6 Other classes 94
8 Streams 132
8.1 Streams- more details 132
8.2 Streams for files 138
8.3 Streams in the drawing package 142
Afterword 190
viii
Preface ix
Acknowledgements
The author wishes to thank the various people who have helped in the
production of the book (known as 'daughter of book' - it is the sister of
Modula-2 Applied which is called 'son of book'): to colleagues in the
Cybernetics Department, to Chris Williams, to friends and family, and to
Malcolm Stewart and his reviewers for guiding the book through its
evolutionary process.
This book is dedicated to two objects in a class of their own, Anne-Marie
and Jacqueline.
Reading 1993