100% found this document useful (6 votes)
587 views

Practical C Programming 2nd Edition Steve Oualline instant download

Ebook

Uploaded by

marylinguea
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (6 votes)
587 views

Practical C Programming 2nd Edition Steve Oualline instant download

Ebook

Uploaded by

marylinguea
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

Practical C Programming 2nd Edition Steve

Oualline pdf download

https://ebookname.com/product/practical-c-programming-2nd-
edition-steve-oualline/

Get Instant Ebook Downloads – Browse at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Practical UML statecharts in C C event driven


programming for embedded systems 2nd Edition Miro Samek

https://ebookname.com/product/practical-uml-statecharts-in-c-c-
event-driven-programming-for-embedded-systems-2nd-edition-miro-
samek/

Thinking in C Volume 2 Practical Programming Bruce


Eckel

https://ebookname.com/product/thinking-in-c-volume-2-practical-
programming-bruce-eckel/

How Not to Program in C 111 Broken Programs and 3


Working Ones or Why Does 2 2 5986 1st Edition Steve
Oualline

https://ebookname.com/product/how-not-to-program-in-c-111-broken-
programs-and-3-working-ones-or-why-does-2-2-5986-1st-edition-
steve-oualline/

The Image of a Country created by International Media


1st Edition Elena Tarasheva

https://ebookname.com/product/the-image-of-a-country-created-by-
international-media-1st-edition-elena-tarasheva/
Broadbandits Inside the 750 Billion Telecom Heist 1st
Edition Om Malik

https://ebookname.com/product/broadbandits-inside-
the-750-billion-telecom-heist-1st-edition-om-malik/

The Struggle for Democracy 9th Edition Edward S.


Greenberg

https://ebookname.com/product/the-struggle-for-democracy-9th-
edition-edward-s-greenberg/

Canine and Feline Nephrology and Urology Second Edition


Dennis J. Chew Dvm Dacvim

https://ebookname.com/product/canine-and-feline-nephrology-and-
urology-second-edition-dennis-j-chew-dvm-dacvim/

Canadian Painters in a Modern World 1925 1955 Writings


and Reconsiderations 2nd Edition Lora Senechal Carney

https://ebookname.com/product/canadian-painters-in-a-modern-
world-1925-1955-writings-and-reconsiderations-2nd-edition-lora-
senechal-carney/

Nanodevices for the Life Sciences Nanotechnologies for


the Life Sciences Volume 4 1st Edition Challa S. S. R.
Kumar

https://ebookname.com/product/nanodevices-for-the-life-sciences-
nanotechnologies-for-the-life-sciences-volume-4-1st-edition-
challa-s-s-r-kumar/
Earthquake Resistant Design of Buildings 1st Edition
Muhammad Hadi (Author)

https://ebookname.com/product/earthquake-resistant-design-of-
buildings-1st-edition-muhammad-hadi-author/
• Table of C ontents
• Index
• Reviews
• Examples
• Reader Reviews
• Errata

Practical C++ Programming


By Steve Oualline

Publisher : O'Reilly
Pub Date : December 2002
ISBN : 0-596-00419-2
Pages : 574

In short, to-the-point chapters, Practical C++ Programming covers all aspects


of programming including style, software engineering, programming design,
object-oriented design, and debugging. It also covers common mistakes and
how to find (and avoid) them. End of chapter exercises help you ensure you've
mastered the material. Steve Oualline's clear, easy-going writing style and
hands-on approach to learning make Practical C++ Programming a nearly
painless way to master this complex but powerful programming language.
• Table of C ontents
• Index
• Reviews
• Examples
• Reader Reviews
• Errata

Practical C++ Programming


By Steve Oualline

Publisher : O'Reilly
Pub Date : December 2002
ISBN : 0-596-00419-2
Pages : 574

C opyright
Preface
Scope of This Handbook
How This Book Is Organized
How to Read This Book If You Already Know C
Font C onventions
How to C ontact Us
Acknowledgments for the First Edition
Acknowledgments for the Second Edition

Part I: The Basics


C hapter 1. What Is C ++?
Section 1.1. A Brief History of C ++
Section 1.2. C ++ Organization
Section 1.3. How to Learn C ++

C hapter 2. The Basics of Program Writing


Section 2.1. Programs from C onception to Execution
Section 2.2. C reating a Real Program
Section 2.3. Getting Help in Unix
Section 2.4. Getting Help in an IDE
Section 2.5. Programming Exercises

C hapter 3. Style
Section 3.1. C omments

Section 3.2. C ++ C ode


Section 3.3. Naming Style
Section 3.4. C oding Religion
Section 3.5. Indentation and C ode Format
Section 3.6. C larity
Section 3.7. Simplicity
Section 3.8. C onsistency and Organization
Section 3.9. Further Reading
Section 3.10. Summary

C hapter 4. Basic Declarations and Expressions


Section 4.1. Basic Program Structure
Section 4.2. Simple Expressions
Section 4.3. The std::cout Output Object
Section 4.4. Variables and Storage
Section 4.5. Variable Declarations
Section 4.6. Integers
Section 4.7. Assignment Statements
Section 4.8. Floating-Point Numbers
Section 4.9. Floating-Point Divide Versus Integer Divide
Section 4.10. C haracters
Section 4.11. Wide C haracters
Section 4.12. Boolean Type
Section 4.13. Programming Exercises
Section 4.14. Answers to C hapter Questions

C hapter 5. Arrays, Qualifiers, and Reading Numbers


Section 5.1. Arrays
Section 5.2. Strings
Section 5.3. Reading Data
Section 5.4. Initializing Variables
Section 5.5. Multidimensional Arrays
Section 5.6. C -Style Strings
Section 5.7. Types of Integers
Section 5.8. Types of Floats
Section 5.9. C onstant and Reference Declarations
Section 5.10. Qualifiers
Section 5.11. Hexadecimal and Octal C onstants
Section 5.12. Operators for Performing Shortcuts
Section 5.13. Side Effects
Section 5.14. Programming Exercises
Section 5.15. Answers to C hapter Questions

C hapter 6. Decision and C ontrol Statements


Section 6.1. if Statement
Section 6.2. else Statement
Section 6.3. How Not to Use std::strcmp
Section 6.4. Looping Statements
Section 6.5. while Statement
Section 6.6. break Statement

Section 6.7. continue Statement


Section 6.8. The Assignment Anywhere Side Effect
Section 6.9. Programming Exercises
Section 6.10. Answers to C hapter Questions

C hapter 7. The Programming Process


Section 7.1. Setting Up Your Work Area
Section 7.2. The Specification
Section 7.3. C ode Design
Section 7.4. The Prototype
Section 7.5. The Makefile
Section 7.6. Testing
Section 7.7. Debugging
Section 7.8. Maintenance
Section 7.9. Revisions
Section 7.10. Electronic Archaeology
Section 7.11. Mark Up the Program
Section 7.12. Use the Debugger
Section 7.13. Use the Text Editor as a Browser
Section 7.14. Add C omments
Section 7.15. Programming Exercises

Part II: Simple Programming


C hapter 8. More C ontrol Statements
Section 8.1. for Statement
Section 8.2. switch Statement
Section 8.3. switch, break, and continue
Section 8.4. Programming Exercises
Section 8.5. Answers to C hapter Questions

C hapter 9. Variable Scope and Functions


Section 9.1. Scope and Storage C lass
Section 9.2. Namespaces
Section 9.3. Functions
Section 9.4. Summary of Parameter Types
Section 9.5. Recursion
Section 9.6. Structured Programming Basics
Section 9.7. Real-World Programming
Section 9.8. Programming Exercises
Section 9.9. Answers to C hapter Questions

C hapter 10. The C ++ Preprocessor


Section 10.1. #define Statement
Section 10.2. C onditional C ompilation
Section 10.3. #include Files
Section 10.4. Parameterized Macros
Section 10.5. Advanced Features
Section 10.6. Summary
Section 10.7. Programming Exercises

Section 10.8. Answers to C hapter Questions

C hapter 11. Bit Operations


Section 11.1. Bit Operators
Section 11.2. The AND Operator (&)
Section 11.3. Bitwise OR (|)
Section 11.4. The Bitwise Exclusive OR (^)
Section 11.5. The Ones C omplement Operator (NOT) (~)
Section 11.6. The Left and Right Shift Operators (<<, >>)
Section 11.7. Setting, C learing, and Testing Bits
Section 11.8. Bitmapped Graphics
Section 11.9. Programming Exercises
Section 11.10. Answers to C hapter Questions

Part III: Advanced Types and C lasses


C hapter 12. Advanced Types
Section 12.1. Structures
Section 12.2. Unions
Section 12.3. typedef
Section 12.4. enum Type
Section 12.5. Bit Members or Packed Structures
Section 12.6. Arrays of Structures
Section 12.7. Programming Exercises
Section 12.8. Answers to C hapter Questions

C hapter 13. Simple C lasses


Section 13.1. Stacks
Section 13.2. Improved Stack
Section 13.3. Using a C lass
Section 13.4. Introduction to C onstructors and Destructors
Section 13.5. Automatically Generated Member Functions
Section 13.6. Shortcuts
Section 13.7. Style
Section 13.8. Structures Versus C lasses
Section 13.9. Programming Exercises

C hapter 14. More on C lasses


Section 14.1. Friends
Section 14.2. C onstant Functions
Section 14.3. C onstant Members
Section 14.4. Static Member Variables
Section 14.5. Static Member Functions
Section 14.6. The Meaning of static
Section 14.7. Programming Exercises

C hapter 15. Simple Pointers


Section 15.1. const Pointers
Section 15.2. Pointers and Printing
Section 15.3. Pointers and Arrays

Section 15.4. The reinterpret_cast

Section 15.5. Pointers and Structures

Section 15.6. C ommand-Line Arguments


Section 15.7. Programming Exercises
Section 15.8. Answers to C hapter Questions

Part IV: Advanced Programming C oncepts


C hapter 16. File Input/Output
Section 16.1. C ++ File I/O
Section 16.2. C onversion Routines
Section 16.3. Binary and ASC II Files
Section 16.4. The End-of-Line Puzzle
Section 16.5. Binary I/O
Section 16.6. Buffering Problems
Section 16.7. Unbuffered I/O
Section 16.8. Designing File Formats
Section 16.9. C -Style I/O Routines
Section 16.10. C -Style C onversion Routines
Section 16.11. C -Style Binary I/O
Section 16.12. C - Versus C ++- Style I/O
Section 16.13. Programming Exercises
Section 16.14. Answers to C hapter Questions

C hapter 17. Debugging and Optimization


Section 17.1. C ode Reviews
Section 17.2. Serial Debugging
Section 17.3. Going Through the Output
Section 17.4. Interactive Debuggers
Section 17.5. Debugging a Binary Search
Section 17.6. Interactive Debugging Tips and Tricks
Section 17.7. Runtime Errors
Section 17.8. Optimization
Section 17.9. How to Optimize
Section 17.10. C ase Study: Inline Functions Versus Normal Functions
Section 17.11. C ase Study: Optimizing a C olor-Rendering Algorithm
Section 17.12. Programming Exercises
Section 17.13. Answers to C hapter Questions

C hapter 18. Operator Overloading


Section 18.1. C reating a Simple Fixed-Point C lass
Section 18.2. Operator Functions
Section 18.3. Operator Member Functions
Section 18.4. Warts
Section 18.5. Full Definition of the Fixed-Point C lass
Section 18.6. Programming Exercises
Section 18.7. Answers to C hapter Questions
C hapter 19. Floating Point

Section 19.1. Floating-Point Format

Section 19.2. Floating Addition/Subtraction


Section 19.3. Multiplication and Division
Section 19.4. Overflow and Underflow
Section 19.5. Roundoff Error
Section 19.6. Accuracy
Section 19.7. Minimizing Roundoff Error
Section 19.8. Determining Accuracy
Section 19.9. Precision and Speed
Section 19.10. Power Series
Section 19.11. Programming Exercises

C hapter 20. Advanced Pointers


Section 20.1. Pointers, Structures, and C lasses
Section 20.2. delete Operator
Section 20.3. Linked Lists
Section 20.4. Ordered Linked Lists
Section 20.5. Doubly Linked Lists
Section 20.6. Trees
Section 20.7. Printing a Tree
Section 20.8. The Rest of the Program
Section 20.9. Data Structures for a C hess Program
Section 20.10. Programming Exercises
Section 20.11. Answers to C hapter Questions

C hapter 21. Advanced C lasses


Section 21.1. Derived C lasses
Section 21.2. Virtual Functions
Section 21.3. Virtual C lasses
Section 21.4. Function Hiding in Derived C lasses
Section 21.5. C onstructors and Destructors in Derived C lasses
Section 21.6. The dynamic_cast Operator
Section 21.7. Summary
Section 21.8. Programming Exercises
Section 21.9. Answers to C hapter Questions

Part V: Other Language Features


C hapter 22. Exceptions
Section 22.1. Adding Exceptions to the Stack C lass
Section 22.2. Exceptions Versus assert
Section 22.3. Programming Exercises

C hapter 23. Modular Programming


Section 23.1. Modules
Section 23.2. Public and Private
Section 23.3. The extern Storage C lass
Section 23.4. Headers
Section 23.5. The Body of the Module

Section 23.6. A Program to Use Infinite Arrays

Section 23.7. The Makefile for Multiple Files

Section 23.8. Using the Infinite Array


Section 23.9. Dividing a Task into Modules

Section 23.10. Module Design Guidelines

Section 23.11. Programming Exercises

C hapter 24. Templates


Section 24.1. What Is a Template?
Section 24.2. Templates: The Hard Way
Section 24.3. Templates: The C ++ Way
Section 24.4. Function Specialization
Section 24.5. C lass Templates
Section 24.6. C lass Specialization
Section 24.7. Implementation Details
Section 24.8. Advanced Features
Section 24.9. Summary
Section 24.10. Programming Exercises

C hapter 25. Standard Template Library


Section 25.1. STL Basics
Section 25.2. C lass List�A Set of Students
Section 25.3. C reating a Waiting List with the STL List
Section 25.4. Storing Grades in a STL Map
Section 25.5. Putting It All Together
Section 25.6. Practical C onsiderations When Using the STL
Section 25.7. Getting More Information
Section 25.8. Exercises

C hapter 26. Program Design


Section 26.1. Design Goals
Section 26.2. Design Factors
Section 26.3. Design Principles
Section 26.4. C oding
Section 26.5. Objects
Section 26.6. Real-World Design Techniques
Section 26.7. C onclusion

C hapter 27. Putting It All Together


Section 27.1. Requirements
Section 27.2. C ode Design
Section 27.3. C oding
Section 27.4. Functional Description
Section 27.5. Testing
Section 27.6. Revisions
Section 27.7. A Final Warning
Section 27.8. Program Files

Section 27.9. Programming Exercises

C hapter 28. From C to C ++


Section 28.1. K&R-Style Functions
Section 28.2. struct

Section 28.3. malloc and free


Section 28.4. Turning Structures into C lasses
Section 28.5. setjmp and longjmp
Section 28.6. Mixing C and C ++ C ode

Section 28.7. Summary


Section 28.8. Programming Exercise

C hapter 29. C ++'s Dustier C orners


Section 29.1. do/while
Section 29.2. goto
Section 29.3. The ?: C onstruct
Section 29.4. The C omma Operator
Section 29.5. Overloading the ( ) Operator
Section 29.6. Pointers to Members
Section 29.7. The asm Statement
Section 29.8. The mutable Qualifier
Section 29.9. Run Time Type Identification
Section 29.10. Trigraphs
Section 29.11. Answers to C hapter Questions

C hapter 30. Programming Adages


Section 30.1. General
Section 30.2. Design
Section 30.3. Declarations
Section 30.4. switch Statement
Section 30.5. Preprocessor
Section 30.6. Style
Section 30.7. C ompiling
Section 30.8. The Ten C ommandments for C ++ Programmers
Section 30.9. Final Note
Section 30.10. Answers to C hapter Questions

Part VI: Appendixes


Appendix A. ASC II Table
Appendix B. Ranges
Appendix C . Operator Precedence Rules
Section C .1. Standard Rules
Section C .2. Practical Subset of the Operator Precedence Rules

Appendix D. C omputing Sine Using a Power Series


Appendix E. Resources
Section E.1. C ompilers
Section E.2. Standard Template Library

Section E.3. Standards

Section E.4. Programming Tools

C olophon
Index
Copyright
Copyright © 2003, 1995 O'Reilly & Associates, Inc.

Printed in the United States of America.

Published by O'Reilly & Associates, Inc., 1005 Gravenstein Highway North,


Sebastopol, CA 95472.

O'Reilly & Associates books may be purchased for educational, business, or


sales promotional use. Online editions are also available for most titles
(http://safari.oreilly.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or
corporate@oreilly.com.

Nutshell Handbook, the Nutshell Handbook logo, and the O'Reilly logo are
registered trademarks 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. The association between the image of an Eastern
chipmunk and the topic of C++ programming is a trademark of O'Reilly &
Associates, Inc.

While every precaution has been taken in the preparation of this book, the
publisher and authors assume no responsibility for errors or omissions, or for
damages resulting from the use of the information contained herein.
Preface
This book is devoted to practical C++ programming. It teaches you not only
the mechanics of the language, but also style and debugging. The entire life
cycle of a program is discussed, including conception, design, writing,
debugging, release, documentation, maintenance, and revision.

Style is emphasized. Creating a good program involves more than just typing
code. It is an art in which writing and programming skills blend to form a
masterpiece. A well-written program not only functions correctly, but also is
simple and easy to understand. Comments allow programmers to include
descriptive text in their programs. Clearly written, well-commented programs
are highly prized.

A program should be as simple as possible. Avoid the use of clever tricks.


Cleverness and complexity can kill programs. This book stresses simple,
practical rules. For example, the 15 operator-precedence rules in C++ can be
simplified to 2:

1. Multiply and divide before you add and subtract.

Put parentheses around everything else.

Consider two programs. One was written by a clever programmer, using all the
tricks. The program contains no comments, but it works. The other is nicely
commented and well structured, but doesn't work. Which program is more
useful? In the long run, the "broken" one is more useful because it can be
fixed and maintained easily. Although the clever one works now, sooner or
later it will have to be modified. The hardest work you will ever have to do is
modifying a cleverly written program.
Scope of This Handbook

This handbook is written for people with no previous programming experience,


for programmers who know C and want to upgrade their skills to C++, and for
those who already know C++ and want to improve their programming style
and reliability. You should have access to a computer and know how to use the
basic functions such as the text editor and file system.

Computer languages are best learned by writing and debugging programs.


Sweating over a broken program at two o'clock in the morning only to find
that you typed = where you should have typed == is a very effective teaching
tool. This book contains many examples of common programming errors.
(They are labeled as broken programs in the text.) You are encouraged to
enter these programs into your computer and then run and debug them. This
process introduces you to common errors using short programs so you will
know how to spot and correct such errors in your own larger programs.
(Instructions for obtaining copies of the programs presented in this book are
located at the end of this preface.)

Several dialects of C++ are presented:

A "generic" Unix compiler that should work on most Unix systems

The GNU C++ compiler, named g++ (available for most Unix systems[1])

[1]The GNU g++ compiler can be obtained from http://www.gnu.org,


or you can contact the Free Software Foundation, Inc., at 675
Massachusetts Avenue, Cambridge, MA 02139, (617) 876-3296.

Borland C++ for MS-DOS/Windows

Microsoft's Visual C++ for MS-DOS/Windows

As far as standard C++ is concerned, there are only minor differences among
the various compilers. This book clearly indicates where compiler differences
can affect the programmer. Specific instructions are given for producing and
running programs using each of these compilers. The book also gives examples
of using the programming utility make for automated program production.
How This Book Is Organized

You must crawl before you walk. In Part I, you learn how to crawl. These
chapters teach you enough to write very simple programs. You start with the
mechanics of programming and programming style. Next, you learn how to use
variables and very simple decision and control statements.

At this point you will have learned enough to create very simple programs;
therefore, in Chapter 7, you embark on a complete tour of the programming
process that shows you how real programs are created.

Chapter 1 gives you an overview of C++, describes its history and uses,
and explains how the language is organized.

Chapter 2 explains the basic programming process and gives you enough
information to write a very simple program.

Chapter 3 discusses programming style. How to comment a program is


covered, as well as how to write clear and simple code.

Chapter 4 introduces simple C++ statements. Basic variables and the


assignment statement are covered in detail along with the arithmetic
operators: +, -, *, /, and %.

Chapter 5 covers arrays and more complex variables. The shorthand


operators ++, -- , *=, =, +=, -=, /=, and %= are described.

Chapter 6 explains simple decision statements including if, else, and for.
The problem of == versus = is discussed.

Chapter 7 takes you through the steps required for creating a simple
program, from specification through release. Fast prototyping and
debugging are discussed.

Part II describes all the other simple statements and operators that are used in
programming. You also learn how to organize these statements into simple
functions.

Chapter 8 describes additional control statements. Included are while,


break, and continue. The switch statement is discussed in detail.

Chapter 9 introduces local variables, namespaces, functions, and


parameters.

Chapter 10 describes the C++ preprocessor, which gives you great


flexibility in creating code. It also provides a tremendous number of ways
for you to screw up. Simple rules that help keep the preprocessor from
becoming a problem are described.

Chapter 11 discusses the logical C++ operators that work on bits.

In Part III you learn how basic declarations and statements can be used in the
construction of advanced types such as structures, unions, and classes. You
also learn about the concept of pointers.

Chapter 12 explains structures and other advanced types. The sizeof


operator and the enum type are included.

Chapter 13 introduces the concept of a class. This is one of the more


powerful features of C++. Classes allow you to group data and the
operations that can be performed on that data into one object.

Chapter 14 describes additional operations that can be performed with


classes.

Chapter 15 introduces C++ pointer variables and shows some of their


uses.

Advanced programming techniques are explored in Part IV. In this section, you
explore a number of C++ features that let you create complex, yet easy-to-
use objects or classes.

Chapter 16 describes both buffered and unbuffered input/output (I/O).


ASCII and binary files are discussed and you are shown how to construct a
simple file. Old C-style I/O operations are also included.

Chapter 17 describes how to debug a program and how to use an


interactive debugger. You are shown not only how to debug a program, but
also how to write a program so that it is easy to debug. This chapter also
describes many optimization techniques to make your programs run faster
and more efficiently.

Chapter 18 explains that C++ allows you to extend the language by


defining additional meanings for the language's operators. In this chapter,
you create a complex type and the operators that work on it.

Chapter 19 uses a simple decimal floating-point format to introduce the


problems inherent in using floating points, such as roundoff errors,
precision loss, overflow, and underflow.

Chapter 20 describes advanced use of pointers to construct dynamic


structures such as linked lists and trees.

Chapter 21 shows how to build complex, derived classes out of simple,


base ones.

Several miscellaneous features are described in Part V.

Chapter 22 explains how to handle unexpected conditions within a


program.

Chapter 23 shows how to split a program into several files and use
modular programming techniques. The make utility is explained in more
detail.

Chapter 24 allows you to define a generic function or class that generates


a family of functions.

Chapter 25 describes the template library that comes with C++. This
library consists of a number of "container templates" and related data
structures which let you create very complex and robust data structures
with very little work.

Chapter 26 discusses some of the methodologies used to design programs,


such as structured programming and object-oriented design. Not only are
the design methods discussed, but also the reasoning that went into the
design of the program.

Chapter 27 details the steps necessary to take a complex program from


conception to completion. Information hiding and modular programming
techniques, as well as object-oriented programming, are stressed.

Chapter 28 describes how to turn C code into C++ code and addresses
many of the traps lurking in C code that bite the C++ programmer.

Chapter 29 describes the little used do/while statement, the comma


operator, and the ?: operators.

Chapter 30 lists programming adages that will help you construct good
C++ programs.

Part VI contains additional C++ reference information.

Appendix A contains a list of character codes and their values.

Appendix B lists the numeric ranges of some C++ variable types.

Appendix C lists the rules that determine the order in which operators are
evaluated.

Appendix D contains a program that shows how the computer can compute
the value of the sine function.

Appendix E lists information on the programming resources mentioned in


the book.
How to Read This Book If You Already Know C

C++ is built on the C language. If you know C, you will find much of the
material presented in Chapter 2 through Chapter 12 familiar.

C++ does introduce a number of new minor improvements to C++, including:

An entirely new I/O system. (The basics are described in Chapter 4. The
new file system is discussed in detail in Chapter 16.)

Constants and reference variables (described in Chapter 5).

Function overloading, inline functions, reference parameters, and default


parameters. (Read Chapter 9.)

So you can use C++ as a better C. But C++ has added some entirely new
features such as objects, templates, and exceptions. So starting with Chapter
13, you will begin to learn entirely new concepts.
Font Conventions

The following conventions are used in this book:

Italic

Used for directories and to emphasize new terms and concepts when they
are introduced. Italic is also used to highlight comments in examples.

Bold

Used for C++ keywords.

Constant width

Used for programs and the elements of a program and in examples to show
the contents of files or the output from commands. A reference in text to a
word or item used in an example or code fragment is also shown in
constant width font.

Constant bold

Used in examples to show commands or other text that should be typed


literally by the user. (For example, rm foo means to type "rm foo" exactly
as it appears in the text or the example.)

Constant italic

Used in examples to show variables for which a context-specific


substitution should be made. (The variable filename, for example, would
be replaced by some actual filename.)

"Quotes"

Used to identify system messages or code fragments in explanatory text.

The Unix C shell prompt.

The Unix Bourne shell or Korn shell prompt.


[]

Surround optional values in a description of program syntax. (The brackets


themselves should never be typed.)

...

Stands for text (usually computer output) that's been omitted for clarity or
to save space.

The notation CTRL-X or ^X indicates use of control characters. It means hold


down the "control" key while typing the character "x". We denote other keys
similarly (e.g., RETURN indicates a carriage return).

All examples of command lines are followed by a RETURN unless otherwise


indicated.
How to Contact Us

Please address comments and questions concerning this book to:

O'Reilly & Associates, Inc.


1005 Gravenstein Highway North
Sebastopol, CA 95472
1-800-998-9938 (in the United States or Canada)
1-707-829-0515 (international or local)
1-707-829-0104 (fax)

There is a web page for this book, which lists errata, examples, or any
additional information. You can access this page at:

http://www.oreilly.com/catalog/cplus2

To comment or ask technical questions about this book, send email to:

bookquestions@oreilly.com

For more information about books, conferences, Resource Centers, and the
O'Reilly Network, see the O'Reilly web site at:

http://www.oreilly.com/
Acknowledgments for the First Edition

Thanks to Peg Kovar for her proofreading and editing help. Special thanks to
Dale Dougherty for ripping apart my first book and forcing me to put it
together correctly. I greatly appreciate the hard work put in by Phil Straite and
Gregory Satir. I especially thank all those people who reviewed and edited my
book. My thanks also go to the production group at O'Reilly & Associates​Nicole
Gipson, project manager and production editor; John Files, Juliette Muellner,
and Jane Ellin, production assistants; and Mike Sierra, book design
implementor. Finally, special thanks go to all the hard-working programmers
out there whose code has taught me so much.
Acknowledgments for the Second Edition

For the second edition I wish to thank my editor, Robert J. Denn, for his
patience and hard work in getting the book done. Thanks to Ray Lischner for
his technical insight. Al Stevens deserves special recognition for his extensive
knowledge of C++ and his exacting standards. His efforts helped me to tighten
the terminology and refine the examples in the book, resulting in a much more
precise manuscript. Any errors in this book are my own and are not the fault
of the reviewers or of the staff at O'Reilly.

Also I wish to give credit to all the sales and marketing people at O'Reilly who
work so hard to sell my book.
Other documents randomly have
different content
Finally, one face on each of the six pieces was pronounced finished,
and the next step was to "joint" or "dress down" one edge straight,
smooth and square with the working face—the first planed surface.
This seemed easier after the experience of making the bench hook,
and Harry knew how to test for squareness with the try square.
Working on the two long pieces for the body, both edges of each
were squared up, a 10-inch piece was marked off on one end of
each with pencil and try square, and sawed off with cross cut saw.
It was decided to leave the inner faces rough, as they would be
inside the trestle, and out of sight. These four pieces forming the
body were now nailed together with 21⁄2-inch wire nails, as shown in
a.
The four pieces for the legs were dressed on all four sides, and it
only remained to cut the angle at top and bottom.
This brought into use a new tool, the bevel. The angle x was found
by laying the bevel on the mechanical drawing, and fixing it at the
angle by tightening the set screw provided for the purpose. The line
was carried across the face by means of the try square, and the
bevel used on the farther edge. When this laying out was finished,
the piece looked like c, the triangular piece y being removed by
sawing directly on the pencil lines.
After the four legs were laid out in this manner and cut, they were
nailed to the body with 3-inch wire nails.
The saw horse was now complete with the exception of the two
braces, and the final truing up.
The braces were made by holding a piece of stock 4 inches × 7⁄8
inch in position and marking the slope with a pencil, sawing to pencil
lines and nailing in position d.
The final process of truing up was an interesting one to Harry, and
he used it many times afterward in finishing pieces of furniture, such
as tables, tabourettes, etc.
The horse was placed on the bench, and a pair of dividers set as
shown at e.
A line was scribed on each leg wherever the compasses point
touched it, holding the latter upright and going around all four sides
of each leg. By sawing to the lines made in this way, the trestle was
found to stand on the floor perfectly true. This is a method much
used in truing up articles that rest on three or more legs, and it
overcomes any inaccuracies that may have arisen in the process of
assembling; but it is very important that the surface on which this
truing up is done shall itself be perfectly true. The bench used in this
case was new and had not yet warped at all, but an old bench might
not have been suitable. This can be ascertained by testing the
surface in several directions with a long straight edge.
The facts of warping and shrinkage in wood must always be taken
into consideration.
The saw horse is an important part of every shop equipment, and
the boys now relegated the clumsy chairs to the kitchen, where they
belonged, and were prepared to saw out stock from their longest
boards.
XVI

BUILDING A LUMBER RACK

Ralph had painted two signs and fastened them in prominent places
on the wall. One read: "One thing at a time"; the other, "A place for
everything, and everything in its place."
"Those are very old-fashioned," he said, "but they are none the less
absolutely true. Many boys fail to accomplish anything in tool work
because they do not heed the first, and more time is wasted than
we ever realize, particularly among mechanics, by failing to observe
the second. It often seems a waste of time to put a tool or piece of
stock away in a definite place, but, on the other hand, one often
spends ten times as many minutes in looking for a thing as he would
putting it in its place where it could be found instantly."
"What's the answer?" said Harry absent-mindedly.
"The answer is that we will make a rack for our lumber before we do
anything else.
"It need not be very fine work, but it will make our shop much
neater, if the surfaces of the wood are planed instead of being left
rough, and to give you practice in planing and to develop your
muscles, I am going to let you do most of the planing, while I lay
out the work."
The rack as finally constructed is shown in Fig. 93. The shop was not
sheathed on the inside, the framework or studding being exposed.
The short cross pieces were nailed to the studding with ten-penny
wire nails, but where they joined the uprights they were let into the
latter to a depth of 1⁄2 inch before being nailed. Harry wanted to
know what this was for, and Ralph explained that if the cross pieces
were simply nailed to the uprights, all the weight would be carried
by the nails. By letting or "gaining" them part way into the uprights,
the weight was carried by the latter without so much strain on the
nails.
"Then why don't you let them into the wall studs too?" asked Harry.
"Because the studs are in position and we couldn't saw them out
without breaking through the outside of the building; therefore we
are obliged simply to nail them on."
Fig. 93. The lumber rack

Four of the uprights were spaced three feet apart, and held in place
at top and bottom by blocks nailed to the ceiling and floor. A
carpenter would have simply "toe-nailed" them by driving nails at an
angle through the ends of the uprights into the floor, but the boys
were not yet skilled in carpenters' methods. An ideal lumber rack is
made of galvanized iron pipe. It is indestructible, fire-proof, rather
expensive, and the joints are regular pipe fitter's joints, elbows, tees,
crosses, and floor plates.
This was beyond our boys' pocket-book, as it would have required
the services of a pipe fitter.
One of the uprights laid out and partly cut is shown at a, the
openings having been taken out with cross cut saw and chisel.
On one of the upper tiers the cross pieces were made eight inches
longer than the others, and where they extended beyond the front
of the rack pieces of pine 6 × 2 × 7⁄8 inches were nailed to the
ends, making a convenient hook for hanging hand screws, which are
always in the way on the floor. It also made a very convenient shelf
for storing narrow waste strips of lumber, which should not be
destroyed, as one can never tell when they will be needed.
In the case of a rack made of iron pipe, the ends of these long cross
pieces need be only ordinary pipe elbows.
The labour of building a lumber rack was much heavier than
anything the boys had done before, but it brought the larger
muscles into play, seemed like real carpenter work, and was an
excellent preparation for the finer tool work to follow. A boy who has
never carried out a piece of large work successfully cannot realize
the satisfaction of looking at a really good piece of construction and
being able to say, "I made that all myself!"
Fig. 94. First wind vane

Ralph suggested that one or two things more were needed to make
their equipment ship-shape—one was a tool cabinet, and another
was some arrangement for storing small pieces of stock; but as both
of these required considerable tool practice, they were recorded in a
notebook as among the things to be done later on.
It was agreed that the shop needed a vane to show the direction of
the wind, and the boys' design for this is shown at Fig. 94. It
included a weather vane and windmill.
The whole combination required five pieces of wood. The two short
pieces, 7 inches long by 1 inch square, were first dressed to size, cut
out and halved together as shown. They were then taken apart and
cut to the lines shown, with a knife, making propeller blades similar
to those made for the aeroplane. When both were finished, they
were again put together, and a hole drilled through the centre a trifle
larger than a flat-head wire nail 21⁄2 inches long. This nail is to hold
the mill to the horizontal piece. The nail is to be tight in this
horizontal piece, but the windmill must revolve freely about the nail.
It is for this reason that the hole in the mill must be slightly larger
than the diameter of the nail.
The horizontal piece is bevelled on one end with the knife and has a
1⁄4-inch slot sawed out at the other. The slot is to receive the wind
vane. The vane was sawed out of 1⁄4-inch wood, fitted into the slot
and nailed with brads.
When all these parts were assembled, it was necessary to find the
centre of gravity of the whole combination, as it is important that it
be perfectly balanced.
To find the correct point, a light string was slipped under the
horizontal piece and moved back and forth until the vane hung
horizontally. The spot where the string touched the wood was
marked with a pencil and a 1⁄4-inch hole drilled at this point for the
pivot. A corresponding hole was drilled 3 inches deep into the
bevelled end of the standard.
A piece of 1⁄4-inch maple dowel was used as a pivot, the upper end
being sand-papered until the vane swung freely. The boys found that
by placing a metal washer between the vane and its standard, much
of the friction was removed. A wire nail driven into the standard
through a hole drilled in the horizontal piece would have answered
the same purpose as the dowel. When the centre of gravity is not
found for the pivot, the vane is apt to tilt forward or backward and
not only look badly, but bring considerable friction on one end, so
that it will not revolve freely with the wind.
XVII

MILLS AND WEATHER VANES

The subject of windmills and weather vanes opened up a field that


seemed inexhaustible, and for a while there was a perfect furore of
designing and experimenting. As usual, Harry wanted to try great
schemes that Ralph knew were impracticable, and it required all his
diplomacy to keep the boy down to earth, on something simple and
within his power to do successfully.
One of his earliest attempts was a scheme to make a windmill on the
principle of a water-wheel, placed horizontally to catch the wind.
Ralph knew that it would not work, but after arguing for some time,
he decided to let the youngster learn by experience. While Harry
was working at his project, Ralph sketched out and made a vane
which he considered an improvement on the first one. It is shown in
Fig. 95; and it was made without a mill and composed of four
pieces. The horizontal piece had an arrow head at the forward end.
At the rear end, two pieces of 1⁄4-inch pine were fastened with two
small bolts. From the point where they were bolted they curved
outward as shown in the top view, and were held in that position by
two small strips nailed on with brads, one on the upper and one on
the lower side. The centre of gravity was found as before, and the
vane pivoted to its standard.
Fig. 95. Second wind vane

In the meantime, Harry had found out to his own satisfaction that
his water-wheel windmill would not work.
"What have you curved those ends out for?" he exclaimed on
catching a sight of Ralph's vane.
"Why, to make it more sensitive to the slightest breeze. Those
curves catch the wind quicker than flat surfaces; have you never
noticed that on the weather bureau vanes they are always curved
out like that?"
"No," said Harry. "By the way, do you know why my mill doesn't
work?"
"I have told you about six times that a water-wheel receives the
water on one side only, while your mill receives the same pressure
on both sides of the centre. The two forces balance, so your mill
can't very well turn. If you could cut off the wind from one side, it
would go all right."
"Well, why can't I box in one side?"
"You can, but then you will have to shift it every time the wind
changes. You could construct a combination mill and vane, and
arrange it so that the box would be shifted by the vane, but
honestly, I don't think it worth the trouble. It would be clumsy, top-
heavy, and hard to balance. I have a scheme for a horizontal mill,
but we will take it up later. In the meantime, let's make a happy jack
windmill!"
"Happy jack?"
"That's what they call them, but we will try to be original and I
propose an Indian with war clubs."
"Whew! That sounds interesting!"
Ralph's sketch of the Indian is shown in Fig. 96. The figure was
sawed out of 1⁄2-inch pine, a 3⁄8-inch hole bored for the arms, and a
1⁄4-inch hole bored for the dowel pivot at the feet. The arms were
made of a piece of dowel, six inches long, with 3⁄16-inch holes bored
near the ends to receive the "clubs." These were whittled out of
pine, each club being a propeller blade. When fastened into the
dowel they formed a complete two-bladed propeller, but this was not
done until the dowel had been inserted through the Indian's
shoulders, and a brad driven through on each side of the body to
keep the arms in place.
Harry was so anxious to see it work
that he came near spoiling it, and had
to be restrained by the older boy, as in
making these toys a well balanced
figure is very important. When it was
finally finished, and placed out in the
wind, the antics of the Indian made
Harry laugh till the tears ran down his
cheeks.
"That's the finest thing we ever made,"
he said. Ralph smiled. It seemed that
he had heard something like that
several times before.
An athlete was suggested, and a bold
figure with outstretched arms was
sketched, as shown in Fig. 97.
Fig. 96. Happy jack The Indian clubs he is supposed to be
swinging were propeller blades, and to
give them more uniform motion than in the case of the Indian, the
hands were drilled and a piece of 1⁄4-inch dowel inserted. At each
end of the dowel was fastened a blade which had been drilled to fit.
Brads were driven through the dowel on each side of the hand to
keep the clubs swinging freely.
The body and arms were cut from a
piece of 1⁄2-inch pine and halved
together across the chest, and after
the joint was made the form of the
body and the arms whittled out with a
knife. The two parts were then
fastened together with brads.
It was important that this figure face
the wind, so into the space between
the ankles was fitted the small end of
a wind vane and the figure securely
fastened to it with brads. The centre of
gravity was then found and the whole
combination pivoted on a generous
piece of 1⁄4-inch dowel.

Fig. 97. An athletic


happy jack
Fig. 98. The anemometer

This athletic weather vane is painted in bright colours, the clubs


being gilded to make them realistic Indian clubs.
"What was that scheme of yours for a horizontal windmill?" asked
Harry after he had watched the athletic club swinger until he was
satisfied.
"Why, to make one on the principle of the anemometer," replied
Ralph.
"How do you spell it?"
"Never mind the spelling, it's like this," and Ralph rapidly sketched
out Fig. 98.
"This is the wind gauge of the weather bureau," he explained, "and I
figure we can use ordinary tin cups for the buckets. You go down to
the hardware store and buy four small round bottomed tin cups
while I start the woodwork."
Having secured the cups for five cents each, they cut the handles
with a pair of tinners' "snips." The cut was made next to the cup at
the lowest point and the handle straightened out even with the top
of the cup.
Two pieces of pine, 16 inches long, 7⁄8-inch wide, and 5⁄8-inch thick,
were halved together at the centre, where a 1⁄4-inch hole was bored
straight through the joint.
A block of wood cut to the shape a was fitted over the joint, and
fastened to the four arms with 1-inch brads. The 1⁄4-inch hole was
now continued almost through this cap to give a long bearing for the
pivot—a ten-penny wire nail with the head filed off. Two 3⁄16-inch
holes were drilled through the handle of each cup and corresponding
holes through the wooden arms. The cups were made fast by
passing 3⁄16-inch bolts through cup handles and arms and tightening
the nuts.
This made a very strong and rigid construction and on testing it by
holding the pivot in the hand out in the breeze the instrument
revolved rapidly.
Altogether it was one of the most substantial and satisfactory things
that they had made, but Ralph was not yet satisfied.
"We might as well have a Coney Island of our own as not," he said.
"You whittle out four propellers, 4 inches long and 1⁄2 inch across,
and I'll show you something," he said.
While Harry was doing this, Ralph sawed out four wooden dirigibles
shown at b, 8 inches long, 3 inches across at the widest part, and
1⁄4 inch thick.

A hole was drilled through the centre of each propeller and another
in the flat stern of each air-ship. The pivots for the propellers were
flat-head wire nails small enough for the blades to revolve freely, but
driven securely into the air-ships.
These were now fastened at the ends of the arms of the
anemometer by attaching two strips of basswood to each ship by
wires. The strips were to hold the ships in the proper position facing
in the direction of motion, which was always the same, no matter in
which direction the wind was blowing.
The upper ends of these strips were brought together, and securely
fastened under one of the bolts by wires.
As the anemometer revolved, centrifugal force sent the air-ships out
as far as the basswood strips would allow.
It was a very interesting fair weather
toy, but the first gale, while having no
effect on the anemometer other than
to make it spin around at terrific
speed, nearly wrecked the ships by
slamming them against the standard. Fig. 99. The Zeppelin
So the boys always took the ships off wind vane
at night, and put them on again when
they wanted to give an exhibition.
The propellers were gilded and the ships painted in bright colours.
A very simple vane may be made to represent a Zeppelin air-ship
(Fig. 99) by cutting out a piece of white pine 2 feet long and 21⁄2
inches wide with the ends pointed to the shape of a Gothic arch. The
hole for the pivot should be bored 2 inches deep and be placed well
forward of the centre. To make the vane balance, the rear portion
from the pivot to the stern should be planed thin and rounded with
the spokeshave.
Fig. 100. A six-bladed mill

At the stern should be a small two-bladed propeller, pivoted on a


flat-head wire nail. If the stern is still too heavy, the balance can be
restored by driving into the forward point a round-headed screw, or
by attaching another small propeller. In fact, if the hole in this
propeller is made large enough, the screw can be used as the pivot;
in any event, the vane must be balanced by adding some kind of
weight at the bow.
These typical forms of wind vanes will suggest others and the young
woodworker should try to be original, to design new forms, ships,
submarines, air-ships, etc.
One form which the boys made was especially substantial and
reliable. A six-bladed mill was constructed as follows:
First: a piece of 7⁄8-inch pine was cut to the form of a hexagon 2
inches across the points.
Second: a 1⁄4-inch hole was bored in the centre of each of the six
edges and a 3⁄16-inch hole through the centre of the hexagon. (Fig.
100.)
Third: six blades were formed from 1⁄2-inch pine 8 inches long, 2
inches wide, tapering down to 1 inch at one end.
Fourth: in the small end a 1⁄4-inch hole was bored at the centre,
about an inch deep.
Fifth: the blades were tapered in thickness from 1⁄2-inch at the small
end to 3⁄16-inch at the wide end, the tapering being done on one
side only, that away from the wind, the side facing the wind being
perfectly flat.
Sixth: dowel pins were glued securely into the holes in the
hexagonal block and into the blades, the latter being turned on the
dowels at an angle of about 30 degrees—1⁄3 a right angle—from the
front face.
Seventh: after the glue had hardened over night, the whole mill was
painted, special attention being given to covering the joint where the
glue held, to prevent the rain from loosening it.
Eighth: two pieces of 1⁄4-inch white wood were cut out to the form
shown at b. These were fastened to the square piece c by two small
bolts.
The wide ends of the vanes were spread and fastened by two small
strips of white wood, by brads as shown.
Ninth: last came the locating of the centre of gravity, after the mill
had been attached by a ten-penny flat-head wire nail. The pivot was
made of a similar nail into the standard, as on previous wind vanes.
XVIII

TOOLS: SAWS

The boys now took up the systematic study of tools, as Ralph


suggested that they had spent time enough on toys and curiosities.
A cutting tool must be constructed with reference to the material it is
to cut. In the machine shop, we find the angle of the cutting edge
large—often 80 degrees—while a razor has a cutting edge of about 5
degrees. All cutting tools are wedges, whether saws, chisels, planes,
axes, or knives, and the angle depends on the hardness of the
material in which it is to work. The action of the tool may be a chisel
action, a knife action, or both. In the rip saw, the teeth are really a
series of chisel edges cut in one piece of steel, while in a cross cut
saw we have a knife action for cutting the fibres, followed by a chisel
action for removing the wood.
The side view of a rip saw is shown at a (Fig. 101), the end view at
b.
The chisel-like edges are bent outward to right and left alternately.
This is called the "set" of the teeth and its purpose is to make the
cut wider than the body of the saw, to prevent friction. As the saw
teeth pass through the wood, the fibres spring back against the saw
blade or body, and the friction makes the work almost impossible
without "set" to the teeth. All woodworking saws must be set, and
special tools called "saw sets" are sold for the purpose of bending
out the teeth.
The rip or slitting saw should only be used for cutting with the grain.
When used across the grain, the action is exactly like that of a
narrow chisel, and it will tear the fibres instead of cutting them.
The teeth of a cross cut saw are
shown in Fig. 102. At a is the side
view, and at b the end view. The teeth
are set and filed to a knife edge. This
gives two parallel lines of knife-like
Fig. 101. Teeth of rip teeth which cut the fibres in two
saw parallel lines, while the body of the
tooth cuts out the wood in the form of
sawdust. All woodworking saws belong to one of these two classes,
and the cutting angles of the teeth are shown in Fig. 103.

Fig. 102. Teeth of cross


cut saw
Photograph by Helen W. Cooke
Learning to Use the Cross Cut Saw.
We are very apt to regard the saw not only
as a very commonplace article, but as a
fixed quantity which has always been the
same and always will be. As a matter of
fact, the saw has gone through a process of
evolution the same as the electric motor,
automobile, and aeroplane. New methods
of its manufacture are constantly being
invented and improvements made in its
construction. Some of the steps in the
process of making a hand saw are: rolling
the steel plate of which the body is made,
hardening, tempering, hammering or
smithing, grinding, polishing, filing, setting,
etching, handling, and blocking.
The handling Fig. 103
refers to the
placing of the wooden handle and
some idea of what it means is
illustrated in Fig. 104, showing two
methods of attaching the apple wood
handle.
Some idea of what the grinding means
is shown by the tapers, or difference in
the thickness of the steel, as shown at
Fig. 105, the thickness in one
thousandths of an inch being given at
the different points. It will be noticed
that not only does the blade decrease
Fig. 104. Two methods in width from the handle out to the
of handling end of the saw, but the thickness
decreases from the teeth to the top
and also from the handle out to the
end. This represents ideal saw construction, and it is found only in
the good makes.

Fig. 105. Thickness of saw blade

The back saw, being strengthened by


a heavy piece of steel along the top, is
made of thinner material, and the
tapers are not necessary, for the back
piece gives rigidity. It removes less
Fig. 106. The back saw wood, but is limited in its action by the
back. It is used chiefly by pattern
makers, and for finer bench work, such as cabinet making, but
should be part of every boy's outfit.
The compass-saw shown at Fig. 107 is used for general purposes,
but is not so necessary as the back saw. It is useful for cutting out
small openings, though it is not as valuable for this purpose as the
turning saw.
Fig. 107. The compass saw

One end of the turning saw can be released from the frame by
removing a pin, passed through a small hole. This is fastened in the
frame again and made to follow a curved line like a fret or coping
saw.

Fig. 108. The turning saw

The number of teeth to the inch varies, and saws are rated as four-
point, five-point, etc., according to the number of points or spaces to
the inch. For very hard woods, a saw with small teeth, i. e., with
more points than ordinary to the inch, should be used; but a boy
who possesses one saw of each kind—a rip, a cross cut, a back saw,
and a turning saw—has all that will be required for ordinary
woodwork.

Fig. 109. Using the rip saw and trestles

In working with the board on trestles, the saw should be held at an


angle of about 45 degrees to the surface. When sawing a board held
in the bench vise, this is not so easily done, but the cut should at
least be started with the tool in the correct position. (Fig. 109).
The hack saw is used for cutting metal, and while not essential for
woodwork, is often valuable for cutting pieces of pipe, rivets, bolts,
screws, and nails and should be added to the outfit when the
finances will allow. (Fig. 110).

Fig. 110. The hack saw for cutting metal

In fact, there is no such thing as a set of tools. Good tools only


should be bought, and the outfit at first should be simple; new ones
can be added from time to time, as they are needed. In this way one
learns the possibilities of his kit much better than by starting with an
elaborate collection.
XIX

TOOLS: PLANES

A boy buying his tool outfit is often bewildered by the array in the
hardware store. He is further confused by the advice of the
salesman, and his own little store of money.
In selecting planes, only three are really necessary for ordinary
work, and this number may even be reduced to two.
Wooden planes are still the favourite tools of some woodworkers,
but iron planes have largely superseded them. A 15-inch iron jack
plane, a 9-inch smoothing plane, and a block plane make a very
good combination for a beginning.
Special planes can be added later, as the finances will allow.
The iron plane with its various parts is shown in Fig. 111. These
refer to either the jack or the smooth plane.
In the block plane there is no cap iron, the cutter or plane iron being
placed with the bevelled side up. There is frequently found on this
tool an adjustment for changing the amount of opening in the mouth
for hard or soft woods.
The plane iron and cap are fastened together with a set screw, and
the cap is removed when it is being ground or sharpened on an
oilstone.
This set screw, which is loosened with a screw-driver, or the edge of
the clamp used as a screw-driver, also allows the distance from the
cutting edge to the cap to be changed for soft or hard woods. These
two irons are fastened into the throat of the plane by the clamp.
The
lever (1)
is for
straighte
ning the
plane
iron, and
the
Fig. 111b. The screw s
smoothing plane is for Fig. 111. The smoothing
adjusting plane
the depth of the cut.
The difference between the jack and smooth planes, aside from the
size, is in the shape of the "cutter" or "bit." In the jack plane, the bit
is ground with a slightly curved cutting edge. This enables the tool
to remove coarse shavings, but leaves a slightly corrugated surface
which must be smoothed with the smoothing plane.
The jack plane also tends to straighten the work, owing to its
greater length. The greater the length, the more does it straighten.
The old-fashioned jointers were made several feet long for this very
purpose.
If a boy can afford only one plane, it should be a jack plane, but the
cutter should be ground straight to act as a smooth plane.
The block plane can be dispensed with better than any of the others,
because the smooth plane can be used on a shooting board for
truing up end grain, the original purpose of the block plane.
The latter plane has no cap, as it works on the ends of the wood
fibres with a shearing or paring action. This is helped by holding the
tool at an angle with the wood, a position not advisable with the
other two tools.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookname.com

You might also like