My Account Log in

1 option

Learning C++ : a hands-on approach / Eric Nagler.

Van Pelt Library QA76.73.C153 N35 2004
Loading location information...

Available This item is available for access.

Log in to request item
Format:
Book
Author/Creator:
Nagler, Eric P.
Language:
English
Subjects (All):
C++ (Computer program language).
Physical Description:
xxviii, 530 pages : illustrations ; 24 cm
Edition:
Third edition.
Place of Publication:
Pacific Grove, CA : Thomson/Brooks/Cole, [2004]
Summary:
With more than 400 examples that are short and easily understood at first viewing, this book serves as the student's classroom notes, tutorial, and reference. LEARNING C++ employs a careful and steady progression of skills and concepts, going beyond the level of detail of most C++ books.
Contents:
1 Transitioning from C to C++ 1
C versus C++ 2
How Does the Compiler Recognize a C++ Program? 2
How Does the Preprocesser Know the Environment? 2
A New Style of Commenting 3
Never Assume! (The Implicit Use of Type int) 3
The Default Return Value from main() 4
The Difference between a Declaration and a Definition 5
Formal Argument Names in Function Declarations 5
Formal Argument Names in Function Definitions 6
All Functions Must Be Declared before Being Called 6
The Meaning of Empty Parentheses 6
Default Function Arguments 7
The Difference between Initialization and Assignment (and Why It's Important) 8
Where to Place Your Variable Declarations 9
Variable Declarations inside a for Loop 9
The Tag Name Becomes the Type Name 10
How Enumerated Types in C++ Differ from C 11
Initialization of Global Variables 12
Array Initialization 13
The Boolean Type bool 14
void * Pointers 15
Use 0, Not the Macro NULL 15
The Keyword const 16
New Styles of Casting 22
C and C++ Keywords 26
2 Namespaces 27
The Problem 28
How to Create a Namespace 29
The Scope Resolution Operator 29
How to Access Members of a Namespace 30
Be Careful to Avoid Ambiguous Situations 33
Unnamed Namespaces 34
Namespace Aliases 35
The Koenig Lookup Rule 36
3 Input/Output Basics 37
Why Switch to Something New? 37
Header File-Naming Conventions 38
The iostream Header File 38
The court Object 39
A Suggestion for Proper Usage of the std Namespace 42
Be Aware of Operator Precedence 43
Formatting the Output 44
The cin Object 44
Checking for End-of-File 45
4 Reference Variables 49
What's the Problem? 49
How to Create a Reference Variable 51
All References Must Be Initialized 52
What's the Point of All This Work? 52
const-Qualifying a Reference 53
When Not to Use a Reference 54
There Is No "Constant Reference" 55
Making a Reference to a Pointer 55
Making a Reference to an Array 57
Returning a Reference from a Function 57
5 Dynamic Memory Allocation 60
How to Allocate Dynamic Memory for a Single Object 60
How to Initialize a Primitive Type 61
The Meaning of Empty Parentheses 62
How to Release the Free Space for a Single Object 62
How to Allocate Free Space for an Array of Objects 63
How to Release the Free Space for an Array of Objects 64
Keep Things in Balance 65
How to Use new and delete to Store Strings on the Free Store 65
How to Allocate and Delete Multidimensional Arrays 67
Name That Space! 69
Do You Understand? 69
6 Introduction to Classes 72
Thinking about Structures in C 72
A First Look at Encapsulation 75
A Structure versus a Class 77
The Purpose of a Class 77
The Components of a Class 78
How to Write a Class Definition 78
Principle of Data Hiding 83
Access Specifiers 85
Modularity and Implementation Hiding 89
How to Access Class Members via Instances 93
Inline Functions 95
mutable Keyword 101
How to Display the Contents of a Class 103
Enumerated Types within Classes 105
7 Constructors and Destructors 113
Constructor Definition 114
Destructor Definition 122
How to Instantiate a Class and Invoke the Default Constructor 124
How to Instantiate a Class and Pass Arguments to the Constructor 125
How to Prevent Instantiations with the Default Constructor 126
Implicit Type Conversion 128
Copy Constructor 132
Function Style Cast 139
Initialization versus Assignment 143
Base/Member Initialization List 144
What about Pointers? 149
Formal Argument Names versus Class Member Names 149
Initialization Order of Nonstatic Data Members 150
A Primitive Type Array as a Nonstatic Data Member 151
An Array of User-Defined Types as a Nonstatic Data Member 152
How to Create an Array of User-Defined Instances 153
How to Declare an Array of Constant Data Members 155
How to Create a Single User-Defined Type on the Free Store 155
How to Create an Array of a User-Defined Type on the Free Store 156
Placement Syntax When Calling new 157
8 More Class Features 163
The this Pointer 163
Static Class Data Members 170
The Size of a Class 183
Friend Functions 184
Friend Classes 192
Encapsulating a Class 197
Operator Conversion Functions 205
Introduction to Pointers to Class Members 207
9 Exception Handling 211
How to Throw an Exception 211
How to Catch an Exception 212
Matching Process for Catch Blocks 213
A Simple Example of Exception Handling 214
Unwinding the Stack 215
What If the Call to new Fails? 215
How to Prevent new from Throwing an Exception 217
Propagating an Exception 217
How to Manage Pointers to the Free Space 219
You Can't Destroy What You Haven't Created 223
Rethrowing an Object 223
Catching Throws from Subobject Members 223
Function-Try-Blocks 225
Mixing Subobject Members and Pointers 227
Partial Construction of an Object 229
Writing Exception-Safe Code 230
Destructors and Exception Handling 237
Exception Specifications 237
Error Conditions 239
How the Compiler Treats Exception Specifications 240
Defining operator new () for a Class 241
10 Function Overloading 245
The Return Type Is Ignored 246
const-Qualifying an Argument Passed by Value 247
const-Qualifying an Argument Passed by Pointer 247
const-Qualifying an Argument Passed by Reference 247
Mutator versus Constant Member Functions 248
Overload Resolution 248
Overloading on a Pointer Type 250
Name Mangling 250
Operator Function Overloading 254
11 Inheritance 287
A Derived Class Instance in Memory 287
Using Inheritance to Create an is-a Relationship 288
How to Define a Derived Class 288
A Structure versus a Class (Revisited) 289
The Keyword protected 290
Access Privileges 291
Base Class "Accessor" Functions 292
Changing the Inherited Access 293
Function Hiding 296
How a Derived Class Member Function Calls a Base Class Member Function 299
Manager Functions 301
Introduction to Polymorphism 311
Polymorphism and Virtual Functions 315
Abstract Base Classes 321
Liskov Substitution Principle 323
Multiple Inheritance 326
12 Templates 335
Function Templates 335
Class Templates 358
Nontype Template Arguments 382
Member Templates 387
Template Models 392
typename Keyword 395
13 Runtime Type Information 399
Dynamic Casting 399
The typeid Keyword 403
14 Iostream Output 410
The Instances std::cerr and std::clog 410
How to Format the Output 411
How to Display a bool Type 430
How to Print an Address 430
How to Output to a Memory Buffer 432
15 Iostream Input 435
How to Check for Errors 435
Character Input 445
16 Manipulators 452
The Format of a Manipulator 452
Some Simple Manipulators 453
Built-In Manipulators Called with No Arguments 456
Manipulators Taking One Argument 458
Built-In Manipulators Taking One Argument 460
17 File Input/Output 462
File Input/Output Classes 462
File Output 464
File Input 467
File Position Markers 468
File Update 469
Binary Mode 471
Unformatted Output 473
Unformatted Input 476
Redirecting I/O 477
18 The string Class and the Standard Template Library 481
The string Class 481
The Standard Template Library 486
Appendix B C++ Guidelines 518.
Notes:
Includes bibliographical references (pages 516-517) and index.
ISBN:
053438966X
9780534389666
OCLC:
52167236

The Penn Libraries is committed to describing library materials using current, accurate, and responsible language. If you discover outdated or inaccurate language, please fill out this feedback form to report it and suggest alternative language.

My Account

Shelf Request an item Bookmarks Fines and fees Settings

Guides

Using the Library Catalog Using Articles+ Library Account