- Catalog Home
- » C++ without fear: a beginner's guide that makes you feel smart
C++ without fear: a beginner's guide that makes you feel smart
Author
Language
English
Description
Loading Description...
Table of Contents
From the Book - 2nd ed.
Machine generated contents note: ch. 1 Your First C++ Programs
Thinking Like a Programmer
Computers Do Only What You Tell Them
Determine What the Program Will Do
Write the Equivalent C++ Statements
Interlude How "Smart" Are Computers, Really?
Some Nerdy Definitions A Review
What's Different About C++?
Building a C++ Program
Enter the Program Statements
Build the Program (Compile and Link)
Test the Program
Revise as Needed
Installing Your Own C++ Compiler
Example 1.1 Print a Message
If You're Using the Dev-C++ Environment
If You're Using Microsoft Visual Studio
How It Works
Exercises
Interlude What about the #include and using?
Advancing to the Next Print Line
Example 1.2 Print Multiple Lines
How It Works
Exercises
Interlude What Is a String?
Storing Data: C++ Variables
Introduction to Data Types
Interlude Why Double Precision, Not Single?
Example 1.3 Convert Temperatures
How It Works
Optimizing the Program
Exercises
A Word about Variable Names and Keywords
Exercise
ch. 1 Summary
ch. 2 Decisions, Decisions
But First, a Few Words about Data Types
Decision Making in Programs
Interlude What about Artificial Intelligence (AI)?
If and if-else
Interlude Why Two Operators (= and ==)?
Example 2.1 Odd or Even?
How It Works
Optimizing the Code
Exercise
Introducing Loops
Interlude Infinite Loopiness
Example 2.2 Print 1 to N
How It Works
Optimizing the Program
Exercises
True and False in C++
Interlude The bool Data Type
The Increment Operator (++)
Statements vs. Expressions
Introducing Boolean (Short-Circuit) Logic
Interlude What Is "true"?
Example 2.3 Testing a Person's Age
How It Works
Exercise
Introducing the Math Library
Example 2.4 Prime-Number Test
How It Works
Optimizing the Program
Exercise
Example 2.5 The Subtraction Game (NIM)
How It Works
Exercises
ch. 2 Summary
ch. 3 The Handy, All-Purpose "for" Statement
Loops Used for Counting
Introducing the "for" Loop
A Wealth of Examples
Interlude Does "for" Always Behave Like "while"?
Example 3.1 Printing 1 to N with "for"
How It Works
Exercises
Compound Statements (Blocks) with "for"
Declaring Loop Variables on the Fly
Example 3.2 Prime-Number Test with "for"
How It Works
Exercise
Comparative Languages 101: The Basic "For" Statement
ch. 3 Summary
ch. 4 Functions: Many Are Called
The Concept of Function
The Basics of Using Functions
Step 1 Declare (Prototype) the Function
Step 2 Define the Function
Step 3 Call the Function
Example 4.1 The avg() Function
How It Works
Function Call a Function!
Exercises
Example 4.2 Prime-Number Function
How It Works
Exercises
Local and Global Variables
Interlude Why Global Variables at All?
Recursive Functions
Example 4.3 Prime Factorization
How It Works
Interlude Interlude for Math Junkies
Exercises
Example 4.4 Euclid's Algorithm for GCF
How It Works
Interlude Who Was Euclid?
Exercises
Interlude Interlude for Math Junkies: Rest of the Proof
Example 4.5 Beautiful Recursion: Tower of Hanoi
How It Works
Exercises
Example 4.6 Random-Number Generator
How It Works
Exercises
Games and More Games
ch. 4 Summary
ch. 5 Arrays: All in a Row...
A First Look at C++ Arrays
Initializing Arrays
Zero-Based Indexing
Interlude Why Use Zero-Based Indexes?
Example 5.1 Print Out Elements
How It Works
Exercises
Example 5.2 How Random Is Random?
How It Works
Exercises
Strings and Arrays of Strings
Example 5.3 Card Dealer #1
How It Works
Exercise
Example 5.4 Card Dealer #2
How It Works
Exercise
Example 5.5 Card Dealer #3
How It Works
Optimizing the Program
Exercise
A Word to the Wise
2-D Arrays: Into the Matrix
Ch. 5 Summary
ch. 6 Pointers: Getting a Handle on Data
What the Heck Is a Pointer, Anyway?
The Concept of Pointer
Interlude What Do Addresses Look Like?
Declaring and Using Pointers
Example 6.1 Print Out Addresses
Example 6.2 The double_it Function
How It Works
Exercises
Swap: Another Function Using Pointers
Example 6.2 Array Sorter
How It Works
Exercises
Pointer Arithmetic
Pointers and Array Processing
Example 6.3 Zero Out an Array
How It Works
Writing More Compact Code
Exercises
ch. 6 Summary
ch. 7 Strings: Analyzing the Text
Text Storage on the Computer
Interlude How Does the Computer Translate Programs?
It Don't Mean a Thing If It Ain't Got That String
String-Manipulation Functions
Example 7.1 Building Strings
How It Works
Exercises
Interlude What about Escape Sequences?
Reading String Input
Example 7.2 Get a Number
How It Works
Exercise
Example 7.3 Convert to Uppercase
How It Works
Exercises
Individual Characters vs. Strings
Example 7.4 Breaking Up Input with Strtok
How It Works
Exercises
The New C++ String Type
Include String-Class Support
Declare and Initialize Variables of Type string
Working with Variables of Type string
Input and Output
Example 7.5 Building Strings with the string Type
How It Works
Exercises
Other Operations on the string Type
ch. 7 Summary
ch. 8 Files: Electronic Storage
Introducing File-Stream Objects
How to Refer to Disk Files
Example 8.1 Write Text to a File
How It Works
Exercises
Example 8.2 Display a Text File
How It Works
Exercises
Text Files vs. "Binary" Files
Interlude Are "Binary Files" Really More Binary?
Introducing Binary Operations
Example 8.3 Random-Access Write
How It Works
Exercises
Example 8.4 Random-Access Read
How It Works
Exercises
ch. 8 Summary
ch. 9 Some Advanced Programming Techniques
Command-Line Arguments
Example 9.1 Display File from Command Line
How It Works
Improving the Program
Interlude The Virtue of Predefined Constants
Exercises
Function Overloading
Interlude Overloading and Object Orientation
Example 9.2 Printing Different Types of Arrays
How It Works
Exercise
The do-while Loop
The switch-case Statement
Multiple Modules
Exception Handling: I Take Exception to That!
Say Hello to Exceptions
Handling Exceptions: A First Attempt
Introducing try-catch Exception Handling
ch. 9 Summary
ch. 10 New Features of C++0x
Overview of C++0x Features
The long long Type (not long long long)
Interlude Why a "Natural" Integer?
Working with 64-Bit Literals (Constants)
Accepting long long Input
Formatting long long Numbers
Example 10.1 Fibonacci: A 64-Bit Example
How It Works
Exercises
Localizing Numbers
Interlude Who Was Fibonacci?
Range-Based "for" (For Each)
Example 10.2 Setting an Array with Range-Based "for"
How It Works
Exercises
The auto and decltype Keywords
The nullptr Keyword
Strongly Typed Enumerations
enum Classes in C++0x
Extended enum Syntax: Controlling Storage
Example 10.3 Rock, Paper, Scissors Game
How It Works
A More Interesting Game
Exercises
Raw String Literals
Ch. 10 Summary
ch. 11 Introducing Classes: The Fraction Class
Object Orientation: Quasi-Intelligent Data Types
Interlude OOP...Is It Worth It?
Point: A Simple Class
Interlude Interlude for C Programmers: Structures and Classes
Private: Members Only (Protecting the Data)
Exmple 11.1 Testing the Point Class
How It Works
Exercises
Introducing the Fraction Class
Inline Functions
Find the Greatest Common Factor
Find the Lowest Common Denominator
Example 11.2 Fraction Support Functions
How It Works
Exercises
Example 11.3 Testing the Fraction Class
How It Works
Interlude A New Kind of #include?
Exercise
Example 11.4 Fraction Arithmetic: add and mult
How It Works
Exercises
ch. 11 Summary
ch. 12 Constructors: If You Build It...
Introducing Constructors
Multiple Constructors (Overloading)
C++0x Only: Initializing Members within a Class
The Default Constructor and a Warning
Interlude Is C++ Out to Trick You with the Default Constructor?
C++0x Only: Delegating Constructors
C++0x Only: Consistent Initialization
Example 12.1 Point Class Constructors
How It Works
Exercises
Example 12.2 Fraction Class Constructors
How It Works
Exercises
Reference Variables and Arguments (&)
The Copy Constructor
Interlude The Copy Constructor and References
Example 12.3 Fraction Class Copy Constructor
How It Works
Exercises
A Constructor from String to Fract
ch. 12 Summary
ch. 13 Operator Functions: Doing It with Class
Introducing Class Operator Functions
Operator Functions as Global Functions
Improve Efficiency with References
Example 13.1 Point Class Operators
How It Works
Exercises
Example 13.2 Fraction Class Operators
How It Works
Optimizing the Code
Exercises
Working with Other Types
The Class Assignment Function (=) The Test-for-Equality Function (==)
A Class "Print" Function
Example 13.3 The Completed Fraction Class
How It Works
Exercises
C++0x Only: User-Defined Literals
Defining a Raw-String Literal
Defining a Cooked Literal
ch. 13 Summary
ch. 14 Dynamic Memory and the String Class
Dynamic Memory: The "new" Keyword
Objects and "new"
Allocating Multiple Data
Interlude Dealing with Problems in Memory Allocation
Example 14.1 Dynamic Memory in Action
How It Works
Exercise
Introducing Class Destructors
Example 14.2 A Simple String Class
How It Works
Exercises
"Deep" Copying and the Copy Constructor
The "this" Keyword
Revisiting the Assignment Operator
Writing a Concatenation Function
Example 14.3 The Complete String Class
How It Works
Exercises
ch. 14 Summary
ch. 15 Two Complete OOP Examples
Introducing Linked Lists
Node Design
Implementing a Simple Linked List
An Alphabetical List
Example 15.1 Names in Alpha Order
How It Works
Dealing with Memory Leaks
C++ Only: Using Smart Pointers to Clean Up
Interlude Recursion vs. Iteration Compared
Exercises
Tower of Hanoi, Animated
Mystack Class Design
Using the Mystack Class
Example 15.2 Animated Tower
How It Works
Exercises
ch. 15 Summary
ch. 16 Easy Programming with STL
Introducing the List Template
Interlude Writing Templates in C++
Creating and Using a List Class
Creating and Using Iterators
C++0x Only: For Each
Interlude Pointers vs. Iterators
Example 16.1 STL Ordered List
How It Works
A Continually Sorted List
Exercises
Designing an RPN Calculator
Interlude A Brief History of Polish Notation
Using a Stack for RPN
Introducing the Generalized STL Stack Class
Example 16.2 Reverse Polish Calculator
How It Works
Exercises
Correct Interpretation of Angle Brackets
ch. 16 Summary
ch. 17 Inheritance: What a Legacy
How to Subclass
Interlude Why "public" Base Classes?
Example 17.1 The FloatFraction Class
How It Works
Exercises
Problems with the FloatFraction Class
C++ Only: Inheriting Base-Class Constructors
Example 17.2 The Completed FloatFraction Class
How It Works
Exercises
Protected Members
Object Containment
Safe Inheritance Through Class Hierarchies
ch. 17 Summary
ch. 18 Polymorphism: Object Independence
A Different Approach to the FloatFraction Class
Virtual Functions to the Rescue!
Interlude What Is the Virtual Penalty?
Example 18.1 The Revised FloatFraction Class
How It Works
Exercise
C++ Only: Requiring Explicit Overrides
"Pure Virtual" and Other Abstract Matters
Abstract Classes and Interfaces
Object Orientation and I/O
cout Is Endlessly Extensible
But cout Is Not Polymorphic
Example 18.2 True Polymorphism: The Printable Class
How It Works
Exercise
A Final Word (or Two)
A Final, Final Word
Appendix D Preprocessor Directives
The #define Directive
The ## Operator (Concatenation)
The defined Function
The #elif Directive
The #endif Directive
The #error Directive
The #if Directive
The #ifdef Directive
The #ifndef Directive
The #include Directive
The #line Directive
The #undef Directive
Predefined Constants
Appendix E ASCII Codes
Appendix F Standard Library Functions
String (C-String) Functions
Data-Conversion Functions
Single-Character Functions
Math Functions
Randomization Functions
Time Functions
Formats for the strftime Function
Appendix G I/O Stream Objects and Classes
Console Stream Objects
I/O Stream Manipulators
Input Stream Functions
Output Stream Functions
File I/O Functions
Appendix H STL Classes and Objects
The STL String Class
The
- Template
The Template
Appendix I Glossary of Terms.
Excerpt
Loading Excerpt...
Author Notes
Loading Author Notes...
Subjects
LC Subjects
More Details
ISBN
9780132673266