Teach Yourself C++ in 21 Days

Teach Yourself C++ in 21 Days

by Jesse Liberty

Paperback(1st ed)

$25.24 $29.99 Save 16% Current price is $25.24, Original price is $29.99. You Save 16%.
View All Available Formats & Editions

Product Details

ISBN-13: 9780672305412
Publisher: Sams
Publication date: 09/22/1994
Edition description: 1st ed
Pages: 848
Product dimensions: 7.39(w) x 9.16(h) x 1.78(d)

About the Author

Jesse Liberty is the author of a dozen books on C++, C# and object-oriented analysis and design. He is president of Liberty Associates, Inc. (http: / /www. LibertyAssociates. com), where he provides .net development, contract programming, mentoring, consulting, and training.

Jesse was a distinguished software engineer at AT&T, a software architect for Xerox and LinkNet (PBS), and vice president of Citibank's Development Division. He lives with his wife, Stacey, and his daughters, Robin and Rachel, in the suburbs of Cambridge, Massachusetts. He supports his books on his Web site at http://www.libertyassociates.com-click on Books and Resources.

Read an Excerpt

Chapter 1: Getting Started

Introduction

Welcome to Sams Teach Yourself C++ in 21 Days! Today you will get started on your way to becoming a proficient C++ programmer.

Today you will learn

  • Why C++ is the emerging standard in software development.
  • The steps to develop a C++ program.
  • How to enter, compile, and link your first working C++ program.

A Brief History of C++

Computer languages have undergone dramatic evolution since the first electronic computers were built to assist in artillery trajectory calculations during World War II. Early on, programmers worked with the most primitive computer instructions: machine language. These instructions were represented by long strings of ones and zeros. Soon. assemblers were invented to nap machine instructions to human-readable and -manageable mnemonics, such as ADD and MOV.

In time, higher-level languages evolved, such as BASIC and COBOL. These languages let people work with something approximating words and sentences, such as Let I = 100. These instructions were translated back into machine language by interpreters and compilers.

An interpreter translates a program as it reads it, turning the program instructions, or code, directly into actions. A compiler translates the code into an intermediary form. This step is called compiling, and it produces an object file. The compiler then invokes a linker, which turns the object file into an executable program.

Because interpreters read the code as it is written and execute the code on the spot, interpreters are easy for the programmer to work with. Today, most interpreted programs are referred to as scripts, and the interpreter itself is often called a Script Engine.

Some languages, such as Visual Basic, call the interpreter the runtime library. .lava calls its runtime interpreter a Virtual Machine (VM), but in this case the VM is provided by the browser (such as Internet Explorer or Netscape).

Compilers introduce the extra steps of compiling the source code (which is readable by humans) into object code (which is readable by machines). This extra step is inconvenient, but compiled programs run very fast because the time-consuming task of translating the source code into machine language is done once (at compile time) and is not required when you execute the program. Another advantage of many compiled languages such as C++ is that you can distribute the executable program to people who don't have the compiler. With an interpreted ]an

For many years, the principal goal of computer programmers was to write short pieces of code that would execute quickly. The program needed to be small because memory was expensive, and it needed to be fast because processing power was also expensive. As computers have become smaller, cheaper, and faster, and as the cost of memory has fallen, these priorities have changed. Today the cost of a programmers time far outweighs the cost of most of the computers in use by businesses. Well-written, easy-to-maintain code is at a premium. Easy to maintain means that as business requirements change, the program can be extended and enhanced without great expense...

Table of Contents

Sams Teach Yourself C++ in 21 Days, Third Edition - Table of Contents

Sams Teach Yourself C++ in 21 Days, Third Edition

  • INTRODUCTION
    • Who Should Read This Book
    • Conventions

WEEK 1 - AT A GLANCE

  • DAY 1 - GETTING STARTED
    • Introduction
    • A Brief History of C++
    • Programs
    • Solving Problems
    • How C++ Evolved
    • Should I Learn C First?
    • C++ and Java
    • The ANSI Standard
    • Preparing to Program
    • Your Development Environment
    • Compiling the Source Code
    • Creating an Executable File with the Linker
    • The Development Cycle
    • HELLO.cpp--Your First C++ Program
    • Getting Started with Visual C++ 6
    • Compile Errors
    • Summary
    • Q&A
    • Workshop

  • DAY 2 - THE PARTS OF A C++ PROGRAM
    • A Simple Program
    • A Brief Look at cout
    • Comments
    • Summary
    • Q&A
    • Workshop

  • DAY 3 - VARIABLES AND CONSTANTS
    • What Is a Variable?
    • Defining a Variable
    • Creating More Than One Variable at a Time
    • Assigning Values to Your Variables
    • typedef
    • When to Use short and When to Use long
    • Wrapping Around an unsigned Integer
    • Characters
    • Constants
    • Enumerated Constants
    • Summary
    • Q&A
    • Workshop

  • DAY 4 - EXPRESSIONS AND STATEMENTS
    • Statements
    • Whitespace
    • Blocks and Compound Statements
    • Expressions
    • Operators
    • Combining the Assignment and Mathematical Operators
    • Increment and Decrement
    • Precedence
    • Nesting Parentheses
    • The Nature of Truth
    • The if Statement
    • Using Braces in Nested if Statements
    • Logical Operators
    • Short Circuit Evaluation
    • Relational Precedence
    • More About Truth and Falsehood
    • Conditional (Ternary) Operator
    • Summary
    • Q&A
    • Workshop

  • DAY 5 - FUNCTIONS
    • What Is a Function?
    • Return Values, Parameters, and Arguments
    • Declaring and Defining Functions
    • Function Prototypes
    • Execution of Functions
    • Local Variables
    • Global Variables
    • Global Variables: A Word of Caution
    • More on Local Variables
    • Func tion Statements
    • More About Function Arguments
    • Parameters Are Local Variables
    • More About Return Values
    • Default Parameters
    • Overloading Functions
    • Special Topics About Functions
    • How Functions Work--A Look Under the Hood
    • Summary
    • Q&A
    • Workshop

  • DAY 6 - BASIC CLASSES
    • Creating New Types
    • Classes and Members
    • Accessing Class Members
    • Private Versus Public
    • Implementing Class Methods
    • Constructors and Destructors
    • const Member Functions
    • Interface Versus Implementation
    • Where to Put Class Declarations and Method Definitions
    • Inline Implementation
    • Classes with Other Classes as Member Data
    • Structures
    • Summary
    • Q&A
    • Workshop

  • DAY 7 - MORE PROGRAM FLOW
    • Looping
    • while Loops
    • do...while Loops
    • do...while
    • for Loops
    • Summing Up Loops
    • switch Statements
    • Summary
    • Q&A
    • Workshop

WEEK 1 - IN REVIEW

WEEK 2 - AT A GLANCE

  • DAY 8 - POINTERS
    • What Is a Pointer?
    • Why Would You Use Pointers?
    • The Stack and the Free Store
    • Memory Leaks
    • Creating Objects on the Free Store
    • Deleting Objects
    • Accessing Data Members
    • Member Data on the Free Store
    • The this Pointer
    • Stray, Wild, or Dangling Pointers
    • const Pointers
    • Pointer Arithmetic
    • Summary
    • Q&A
    • Workshop

  • DAY 9 - REFERENCES
    • What Is a Reference?
    • Using the Address of Operator & on References
    • What Can Be Referenced?
    • Null Pointers and Null References
    • Passing Function Arguments by Reference
    • Understanding Function Headers and Prototypes
    • Returning Multiple Values
    • Passing by Reference for Efficiency
    • When to Use References and When to Use Pointers
    • Mixing References and Pointers
    • Don't Return a Reference to an Object That Isn't in Scope!
    • Returning a Reference to an Object on the Heap
    • Pointer, Pointer, Who Has the Pointer?
    • Summary
    • Q&A
    • Workshop

  • DAY 10 - ADVANCED FUNCTIONS
    • Overloaded Member Functions
    • Using Default Values
    • Choosing Between Default Values and Overloaded Functions
    • The Default Constructor
    • Overloading Constructors
    • Initializing Objects
    • The Copy Constructor
    • Operator Overloading
    • Conversion Operators
    • Summary
    • Q&A
    • Workshop

  • DAY 11 - INHERITANCE
    • What Is Inheritance?
    • Inheritance and Derivation
    • Private Versus Protected
    • Constructors and Destructors
    • Overriding Functions
    • Virtual Methods
    • Summary
    • Q&A
    • Workshop

  • DAY 12 - ARRAYS AND LINKED LISTS
    • What Is an Array?
    • Array Elements
    • Writing Past the End of an Array
    • Fence Post Errors
    • Initializing Arrays
    • Declaring Arrays
    • Arrays of Objects
    • Multidimensional Arrays
    • Initializing Multidimensional Arrays
    • A Word About Memory
    • Arrays of Pointers
    • Declaring Arrays on the Free Store
    • A Pointer to an Array Versus an Array of Pointers
    • Pointers and Array Names
    • Deleting Arrays on the Free Store
    • char Arrays
    • strcpy() and strncpy()
    • String Classes
    • Linked Lists and Other Structures
    • A Linked List Case Study
    • The Component Parts
    • What Have You Learned, Dorothy?
    • Array Classes
    • Summary
    • Q&A
    • Workshop

  • DAY 13 - POLYMORPHISM
    • Problems with Single Inheritance
    • Multiple Inh eritance
    • Virtual Inheritance
    • Abstract Data Types
    • The Observer Pattern
    • Summary
    • Q&A
    • Workshop

  • DAY 14 - SPECIAL CLASSES AND FUNCTIONS
    • Static Member Data
    • Static Member Functions
    • Pointers to Functions
    • Pointers to Member Functions
    • Summary
    • Q&A
    • Workshop

WEEK 2 - IN REVIEW

WEEK 3 - AT A GLANCE

  • DAY 15 - ADVANCED INHERITANCE
    • Containment
    • Implementation in Terms of Inheritance/ Containment Versus Delegation
    • Delegation
    • Private Inheritance
    • Friend Classes
    • Friend Functions
    • Friend Functions and Operator Overloading
    • Overloading the Insertion Operator
    • Summary
    • Q&A
    • Workshop

  • DAY 16 - STREAMS
    • Overview of Streams
    • Buffering
    • Streams and Buffers
    • Standard I/O Objects
    • Redirection
    • Input Using cin
    • Other Member Functions of cin
    • Output with cout
    • Related Functions
    • Manipulators, Flags, and Formatting Instructions
    • Streams Versus the printf() Function
    • File Input and Output
    • ofstream
    • Binary Versus Text Files
    • Command-Line Processing
    • Summary
    • Q&A
    • Workshop

  • DAY 17 - NAMESPACES
    • Getting Started
    • Functions and Classes Are Resolved by Name
    • Creating a Namespace
    • Using a Namespace
    • The using Keyword
    • The Namespace Alias
    • The Unnamed Namespace
    • The Standard Namespace std
    • Summary
    • Q&A

  • DAY 18 - OBJECT-ORIENTED ANALYSIS AND DESIGN
    • Is C++ Object-Oriented?
    • Building Models
    • Software Design: The Modeling Language
    • Software Design: The Process
    • The Vision
    • Requirements Analysis
    • Design
    • Summary
    • Q&A
    • Workshop

  • DAY 19 - TEMPLATES
    • What Are Templates?
    • Parameterized Types
    • Template Definition
    • Template Functions
    • Templates and Friends
    • Using Template Items
    • The Standard Template Library
    • Containers
    • Understanding Sequence Containers
    • Stacks
    • Understanding Queues
    • Understanding Associative Containers
    • Algorithm Classes
    • Summary
    • Q&A
    • Workshop

  • DAY 20 - EXCEPTIONS AND ERROR HANDLING
    • Bugs, Errors, Mistakes, and Code Rot
    • Exceptions
    • Using try Blocks and catch Blocks
    • Data in Exceptions and Naming Exception Objects
    • Exceptions and Templates
    • Exceptions Without Errors
    • Bugs and Debugging
    • Summary
    • Q&A
    • Workshop

  • DAY 21 - WHAT'S NEXT
    • The Preprocessor and the Compiler
    • Seeing the Intermediate Form
    • Using #define
    • Inclusion and Inclusion Guards
    • Macro Functions
    • Inline Functions
    • String Manipulation
    • Predefined Macros
    • assert()
    • Bit Twiddling
    • Style
    • Next Steps
    • Summary
    • Q&A

WEEK 3 - IN REVIEW

  • APPENDIXES

  • APPENDIX A - OPERATOR PRECEDENCE

  • APPENDIX B - C++ KEYWORDS

  • APPENDIX C - BINARY AND HEXADECIMAL
    • Other Bases
    • Around the Bases
    • Hexadecimal

  • APPENDIX D - ANSWERS

  • INDEX

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews

Teach Yourself C++ in 21 Days 1 out of 5 based on 0 ratings. 1 reviews.
Guest More than 1 year ago
I don't recommend this book unless u have previous programming knowledge.