301x Filetype PDF File size 2.85 MB Source: www.mimuw.edu.pl
Practical C++ Programming
Steve Oualline
O'Reilly & Associates, Inc.
Beijing · Cambridge · Köln · Paris · Sebastopol · Taipei · Tokyo
Page iv
Practical C++ Programming
by Steve Oualline
Copyright © 1995 O'Reilly & Associates, Inc. All rights reserved.
Printed in the United States of America.
Editors: Adrian Nye and Dale Dougherty
Production Editor: Nicole Gipson
Printing History:
August 1995 First Edition.
January 1997: Minor corrections.
Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are registered
trademarks and The Java Series is a trademark of O'Reilly & Associates, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in this book, and O'Reilly &
Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or
initial caps.
While every precaution has been taken in the preparation of this book, the publisher assumes no
responsibility for errors or omissions, or for damages resulting from the use of the information
contained herein.
This book is printed on acid-free paper with 85% recycled content, 15% post-consumer waste.
O'Reilly & Associates is committed to using paper with the highest recycled content available
consistent with high quality.
ISBN. 1-56592-139-9 [12/98]
Page v
Table of Contents
Preface xv
I: The Basics 1
1: What Is C++? 3 3
A Brief History of C++ 3
C++ Organization 4
How to Learn C++ 6
2: The Basics of Program Writing 9
Programs from Conception to Execution 12
Creating a Real Program 13
Creating a Program Using a Command-Line Compiler 13
Creating a Program Using an Integrated Development Environment 16
Getting Help in UNIX 32
Getting Help in an Integrated Development Environment 33
Programming Exercises 33
3: Style 35
Comments 36
C++ Code 4 41
Naming Style 42
Coding Religion 43
Indentation and Code Format 43
Page vi
Clarity 44
44
Simplicity 45
Consistency and Organization 46
Further Reading 46
Summary 46
4: Basic Declarations and Expressions 49
The Elements of a Program 49
Basic Program Structure 50
Simple Expressions 51
The cout Output Class 53
Variables and Storage 53
Variable Declarations 54
Integers 55
Assignment Statements 56
Floating Point Numbers 57
Floating Point Versus Integer Divide 58
Characters 59
Programming Exercises 60
Answers Chapter Questions 61
5: Arrays, Qualifiers, and Reading Numbers 63
Arrays 63
Strings 64
Reading Data 67
Initializing Variables 69
Multidimensional Arrays 70
Types of Integers 72
Types of Floats 74
74
Constant and Reference Declarations 74
Qualifiers 76
Hexadecimal and Octal Constants 78
Operators for Performing Shortcuts 78
Side Effects 79
Programming Exercises 82
Answers to Chapter Questions 82
Page vii
6: Decision and Control Statements 85
if Statement 85
else Statement 87
How Not to Use strcmp 88
Looping Statements 88
while Statement 88
Break Statement 91
continue Statement 92
The Assignment Anywhere Side Effect 92
Programming Exercises 94
Answers to Chapter Questions 95
7. The Programming Process 97
Setting Up 99
The Specification 100
Code Design 101
The Prototype 102
The Makefile 103
no reviews yet
Please Login to review.