C++ from the Ground Up, Third Edition


Your Fast-Paced Guide to C++ Success!

No one teaches C++ better than Herb Schildt. That's why his books are the choice of millions worldwide. Now you, too, can quickly master C++ using his proven method. In this fully updated new edition, Herb explains the C++ language, from its fundamentals to its most advanced features. You'll start with an overview of C++ and the general form of a C++ program. You'll then learn essentials such as control statements, operators, variables, ...

See more details below
Paperback (Subsequent)
BN.com price
(Save 24%)$45.00 List Price

Pick Up In Store

Reserve and pick up in 60 minutes at your local store

Other sellers (Paperback)
  • All (18) from $1.99   
  • New (6) from $25.19   
  • Used (12) from $1.99   
Sending request ...


Your Fast-Paced Guide to C++ Success!

No one teaches C++ better than Herb Schildt. That's why his books are the choice of millions worldwide. Now you, too, can quickly master C++ using his proven method. In this fully updated new edition, Herb explains the C++ language, from its fundamentals to its most advanced features. You'll start with an overview of C++ and the general form of a C++ program. You'll then learn essentials such as control statements, operators, variables, classes, and objects. Then it's on to exceptions, templates, namespaces, run-time type ID, and the Standard Template Library (STL). There is even a synopsis of the extended keywords used for .NET programming--all presented in Herb's clear, crisp, uncompromising style.

You will learn about:

  • The general form of a C++ program
  • Data types, operators, and expressions
  • Control statements
  • Functions
  • Pointers and references
  • Classes and objects
  • Function and operator overloading
  • Constructors and destructors
  • Templates
  • Exception handling
  • Inheritance
  • Virtual functions
  • The C++ I/O system
  • Run-time type ID
  • Namespaces
  • The Standard Template Library (STL)
  • Object-oriented programming (OOP) principles
  • And much, much more!

This guide teaches programming in C++ to those who have no C background. Readers will learn the fundamentals of the C++ programming language, along with function basics, class fundamentals, virtual functions, the C++ I/O system, and more. The book features a plethora of screens and charts that enhance the clear instructions, practical examples, and valuable tips.

Read More Show Less

Product Details

  • ISBN-13: 9780072228977
  • Publisher: McGraw-Hill Professional Publishing
  • Publication date: 3/19/2003
  • Series: From the Ground Up Series
  • Edition description: Subsequent
  • Edition number: 3
  • Pages: 624
  • Sales rank: 984,119
  • Product dimensions: 9.04 (w) x 7.34 (h) x 1.30 (d)

Meet the Author

Herbert Schildt is a world leading programming author. He is an authority on the C, C++, Java, and C# programming languages, and a master Windows programmer. His programming books have sold more than three million copies worldwide and have been translated into all major foreign languages. He is the author of numerous best sellers including C: The Complete Reference, Java 2: The Complete Reference, Java 2: A Beginner's Guide, C#: A Beginner's Guide, and many more. Schildt holds a master's degree in computer science from the University of Illinois.
Read More Show Less

Read an Excerpt

Chapter 1: The Story of C++


What Is Object-Oriented Programming?

Since object-oriented programming was fundamental to the development of C++, it is important to define precisely what object-oriented programming is. Object-oriented programming has taken the best ideas of structured programming and has combined them with several powerful concepts that allow you to organize your programs more effectively. In general, when programming in an object-oriented fashion, you decompose a problem into its constituent parts. Each component becomes a self-contained object that contains its own instructions and data related to that object. Through this process, complexity is reduced and you can manage larger programs.

All object-oriented programming languages have three things in common: encapsulation, polymorphism, and inheritance. Although we will examine these concepts in detail later in this book, let's take a brief look at them now.


As you probably know, all programs are composed of two fundamental elements: program statements (code) and data. Code is that part of a program that performs actions, and data is the information affected by those actions. Encapsulation is a programming mechanism that binds together code and the data it manipulates, and that keeps both safe from outside interference and misuse. In an object-oriented language, code and data may be bound together in such a way that a self-contained black box is created. Within the box are all necessary data and code. When code and data are linked together in this fashion, an object is created. In other words, an object is the device that supportsencapsulation.

Within an object, the code, data, or both may be private to that object or public. Private code or data is known to, and accessible only by, another part of the object. That is, private code or data may not be accessed by a piece of the program that exists outside the object. When code or data is public, other parts of your program may access it even though it is defined within an object. Typically, the public parts of an object are used to provide a controlled interface to the private elements of the object.


Polymorphism (from the Greek, meaning "many forms") is the quality that allows one interface to be used for a general class of actions. The specific action is determined by the exact nature of the situation. A simple example of polymorphism is found in the steering wheel of an automobile. The steering wheel (i.e., the interface) is the same no matter what type of actual steering mechanism is used. That is, the steering wheel works the same whether your car has manual steering, power steering, or rack-and-pinion steering. Therefore, once you know how to operate the steering wheel, you can drive any type of car. The same principle can also apply to programming. For example, consider a stack (which is a first-in, last-out list). You might have a program that requires three different types of stacks. One stack is used for integer values, one for floating-point values, and one for characters. In this case, the algorithm that implements each stack is the same, even though the data being stored differs. In a non-object-oriented language, you would be required to create three different sets of stack routines, calling each set by a different name, with each set having its own interface. However, because of polymorphism, in C++ you can create one general set of stack routines (one interface) that works for all three specific situations. This way, once you know how to use one stack, you can use them all.

More generally, the concept of polymorphism is often expressed by the phrase "one interface, multiple methods." This means that it is possible to design a generic interface to a group of related activities. Polymorphism helps reduce complexity by allowing the same interface to be used to specify a general class of action. It is the compiler's job to select the speciflc action (i.e., method) as it applies to each situation. You, the programmer, don't need to do this selection manually. You need only remember and utilize the general interface.

The first object-oriented programming languages were interpreters, so polymorphism was, of course, supported at run time. However, C++ is a compiled language. Therefore, in C++, both run-time and compile-time polymorphism are supported.


Inheritance is the process by which one object can acquire the properties of another object. The reason this is important is that it supports the concept of hierarchical classification. If you think about it, most knowledge is made manageable by hierarchical (i.e., top-down) classifications. For example, a Red Delicious apple is part of the classification apple, which in turn is part of the fruit class, which is under the larger class food. That is, the food class possesses certain qualities (edible, nutritious, etc.) that also apply, logically, to its fruit subclass. In addition to these qualities, the fruit class has specific characteristics (juicy, sweet, etc.) that distinguish it from other food. The apple class defines those qualities specific to an apple (grows on trees, not tropical, etc.). A Red Delicious apple would, in turn, inherit all the qualities of all preceding classes, and would define only those qualities that make it unique. Without the use of hierarchies, each object would have to explicitly define all of its characteristics. However, using inheritance, an object needs to define only those qualities that make it unique within its class. It can inherit its general attributes from its parent. Thus, it is the inheritance mechanism that makes it possible for one object to be a specific instance of a more general case.

C++ Implements OOP

As you will see as you progress through this book, many of the features of C++ exist to provide support for encapsulation, polyrnorphism, and inheritance. Remember, however, that you can use C++ to write any type of program, using any type of approach. The fact that C++ supports object-oriented programming does not mean that you can only write object-oriented programs. As with its predecessor, C, one of C++'s strongest advantages is its flexibility.

How C++ Relates to Java

As you are probably aware, there is a relatively new force in computer programming languages, called Java. Java is the language of the Internet. It was strongly influenced by C++. Java and C++ both use the same basic syntax, and Java's object-oriented features are similar to C++'s. In fact, at first glance it is possible to mistake a Java program for a C++ program. Because of their surface similarities, it is a common misconception that Java is simply an alternative to C++. Before continuing, it is necessary to set the record straight on this account. Although related, Java and C++ were designed to solve differing sets of problems. C++ is optimized for the creation of high-performance programs. Towards this end, C++ compiles to highly efficient, executable code. Java is optimized for the creation of portable programs. To obtain portability, Java compiles to pseudo-code (called Java bytecode), which is usually interpreted. This makes Java code very portable, but not very efficient. Thus, Java is excellent for Internet applications, which must work on a wide variety of computers. But for high-performance programs, C++ will remain the language of choice. Because of the similarities between Java and C++, most C++ programmers can readily learn Java. The skills and knowledge you gain in C++ will translate easily. Likewise, if you already know Java, then you will have no trouble learning C++. Keep in mind, however, that some important differences do exist, so be careful not to jump to false conclusions.

What You Will Need

To use this book effectively, you will need a computer and a C++ compiler. The best way to learn is to try the examples yourself, experimenting with your own variations. There really is no substitute for hands-on experience.

If you are using a PC, then you have several C++ compilers from which to choose. just make sure that you use an up-to-date C++ compiler. The code in this book complies with Standard C++ and has been tested with Microsoft C++. It should work with virtually any contemporary C++ compiler. It is best, however, if you can use a compiler that accepts the version of C++ specified by the ANSI/ISO standards committee (i.e., Standard C++).

Now that you know the story behind C++, it is time to start learning how to use it. The next chapter introduces you to the C++ fundamentals...

Read More Show Less

Table of Contents

1 The Story of C++ 1
2 An Overview of C++ 11
3 The Basic Data Types 33
4 Program Control Statements 57
5 Arrays and Strings 81
6 Pointers 105
7 Functions, Part One: The Fundamentals 127
8 Functions, Part Two: References, Overloading, and Default Arguments 157
9 More Data Types and Operators 181
10 Structures and Unions 215
11 Introducing the Class 245
12 A Closer Look at Classes 273
13 Operator Overloading 299
14 Inheritance 331
15 Virtual Functions and Polymorphism 357
16 Templates 375
17 Exception Handling 395
18 The C++ I/O System 417
19 Run-Time Type ID and the Casting Operators 451
20 Namespaces and Other Advanced Topics 471
21 Introducing the Standard Template Library 499
22 The C++ Preprocessor 547
A C-Based I/O 563
B Working with an Older C++ Compiler 581
C The .NET Managed Extensions to C++ 585
Index 591
Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)