Click Here!
home account info subscribe login search FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
[an error occurred while processing this directive]
Previous Table of Contents Next


INTRODUCTION

Despite the development of several new languages over the past five years, C++ has held its own in the development world. Originally developed at AT&T Bell Laboratories by Bjarne Stoustrup, the language has evolved to encompass ever more object-oriented concepts.

With the latest ANSI revision of C++, version 3, the language gets some fine-tuning in memory management, solid exception support, and new typecasting operators. The biggest improvement, however, was the introduction of the Standard Template Library (STL), which provides a standard set of container classes and the means to work with them. Before this, most compiler vendors included their own container classes and other objects in their libraries, posing an impediment to porting code from one platform to another where the same vendor’s compiler was not supported.

What makes C++ so useful? Some people say that its C language underpinnings are great for getting as close to the hardware as possible without using assembler code. Developers find that the strong typing by the C++ language helps reduce the number of bugs in programs. Some people use C++ as “just a better C,” but the point is missed then: The object-oriented programming (OOP) style makes it easier to translate from the problem language and problem world to the solution language.

The great misconception of many people is that object-oriented programming produces slower code. This is not necessarily so. If a problem can be put so that a human mind can understand it better, it is likely that this mind can produce a better solution. Algorithms, and their efficiency, have a much greater impact on program performance than the language does. C++ is only marginally slower than C code overall, and this makes it one of the fastest executing languages for object-oriented programming.

This book is intended to be an eye-opener for C++ programmers. I admit freely that I learn the most from reading other peoples’ code, as I learn their approaches to problems. It’s easy to get stuck in one way of doing things, and this is dangerous with any creative exercise. Computer programming is no exception. What’s written in this book is not gospel, but yet another approach that can be added to your arsenal.

The Waite Group’s C++ How-To is divided into 15 chapters, each of which covers a specific feature of the C++ programming language:

  Chapter 1, “A Quick Introduction to the Language”—Before diving into the “deep end” of C++ programming, this chapter provides a gentle introduction into the basic concepts of the language. Loops, calculations, and error handling are all covered here for the beginning C++ programmer.
  Chapter 2, “Object Orientation—Theory and Practice”—To fully make use of the C++ language, object-oriented programming must be understood. Many C, Pascal, and COBOL programmers are assigned to C++ projects and never take the time—or get the opportunity—to fully learn the benefits of OOP. Without focusing on the specific syntax used in C++, this chapter covers the basic object-oriented concepts required to become a great C++ programmer.
  Chapter 3, “Object Orientation—C++ Specifics”—After learning or reviewing the basic concepts of object-oriented programming in Chapter 2, you will learn how these concepts are specifically applied to C++ in this chapter. The basic tenets of OOP—inheritance, polymorphism, and encapsulation—are all covered here as well as the fundamental C++ unit: the class.
  Chapter 4, “Structures Versus Classes”—C++ provides two primary devices that can be used to contain data: structures and classes. Although the two data structures can be identical, classes are much more powerful because they fully support the primary OOP constructs. This chapter compares and contrasts these two data types and provide numerous examples of their use.
  Chapter 5, “Common Mistakes Made with Classes”—Because of the tremendous difference between traditional structured programming and object-oriented programming, many beginning-to-intermediate–level programmers make several common mistakes. This chapter introduces these mistakes, explains why they are mistakes, and offers solutions to them.
  Chapter 6, “Template Classes”—The template class is a mechanism that enables you to write a single solution to a problem that can satisfy all data types. The actual data type required can be specified later, and the template class can then be used for a wide range of data types, all using the same C++ template. This chapter introduces the template class, or templates as they are commonly known.
  Chapter 7, “The Standard Template Library’s Container Classes”—In this chapter, you will explore the following containers of the Standard Template Library: vector, string, stack, list, and queue. I also discuss iterators and their role in the STL framework. Finally, you will survey some other containers as well as “almost container” classes of the Standard Library.
  Chapter 8, “The Standard C Library’s Included Algorithms”—In this chapter, I survey the algorithms of the Standard C Library. These algorithms enable you to sort an array and find an element in it. In addition, I discuss the random number generation functions of the Standard C Library.
  Chapter 9, “The Standard Template Library’s Included Algorithms”—STL algorithms are represented by template functions and provide copying, searching, sorting, and merging functions, as well as other operations on data. Algorithms are not member functions; they are separate from the container classes. You will examine a number of these algorithms in this chapter. I give examples, where possible, showing their use in typical situations.
  Chapter 10, “C-Style Error Handling”—This chapter covers different error-handling methods that work in C and C++ programs and some methods that don’t work well in C++ programs. Although this is a C++ book, I discuss C-type error-handling techniques so that you will know what you are dealing with if you run into them in older C and C++ programs.
  Chapter 11, “Exception Handling in C++”—The exception-handling mechanism furnished by the standard provides a common and standard interface for handling program anomalies. Without exception handling, error handling is performed using return values from functions and global status variables. Each developer has his or her own style of handling errors, leading to inconsistency among applications and library packages. In this chapter, you will see various ways to apply the exception-handling mechanisms.
  Chapter 12, “new and delete Versus malloc() and free()”—This chapter compares and contrasts the C++ new and delete operators and the C functions malloc() and free(), and it covers their place in C++ memory management. You must understand memory management using C and C++ techniques because of the existence of legacy code and because many existing libraries use the older C language techniques.
  Chapter 13, “Memory Management Techniques Using Classes”—Whereas C-style memory management basically requires the programmer to free variables that have been created, C++-style memory management is much more powerful, although a bit more challenging. This chapter focuses on many advanced memory management techniques that you can use to improve the reliability and performance of your applications.
  Chapter 14, “Understanding the I/O Streams Library”—So many programmers seem to have difficulty with the C++ I/O Streams library that it is quite common to see C++ code still using the old C stdio functions to handle program I/O. Although some programmers might consider this approach practical, or even superior, the C stdio library does not do much to help good programming practice or catch oversights made by the programmer. This chapter introduces the basic concepts required to use the Streams library and shows why it is a preferred solution to the standard C method.
  Chapter 15, “File I/O”—This chapter covers IOStreams with a focus on file streams. Examples are provided that demonstrate how to seek through files, read/write binary files, and manage file I/O errors.

This book also includes two appendixes, one on namespaces and another on runtime type information (RTTI).

WHO IS THIS BOOK INTENDED FOR?

The Waite Group’s C++ How-To is designed for C++ programmers of all skill levels, from beginning to advanced. However, I anticipate that readers who pick up this book already have a solid understanding of C++ programming and are looking for “just the answers” to specific programming questions. This is also a great supplemental resource for new C++ programmers searching for information and instruction that goes beyond a typical tutorial.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-1999 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permision of EarthWeb is prohibited.