Copyright 2004 by The McGraw-Hill Companies. All rights reserved. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher.
ISBN: 978-0-07-181172-9
MHID: 0-07-181172-9
The material in this eBook also appears in the print version of this title: ISBN: 978-0-07-223215-8, MHID: 0-07-223215-3.
All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Where such designations appear in this book, they have been printed with initial caps.
McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs. To contact a representative please e-mail us at bulksales@mcgraw-hill.com.
TERMS OF USE
This is a copyrighted work and The McGraw-Hill Companies, Inc. (McGraw-Hill) and its licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hills prior consent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated if you fail to comply with these terms.
THE WORK IS PROVIDED AS IS. McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting therefrom. McGraw-Hill has no responsibility for the content of any information accessed through the work. Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise.
About the Author
Herbert Schildt is the worlds leading programming author. He is an authority on the C, C++, Java, and C# languages, and is a master Windows programmer. His programming books have sold more than 3 million copies worldwide and have been translated into all major foreign languages. He is the author of numerous bestsellers, including C++: The Complete Reference, C#: The Complete Reference, Java 2: The Complete Reference, C#: A Beginners Guide, Java 2: A Beginners Guide, and C: The Complete Reference. Schildt holds a masters degree in computer science from the University of Illinois. He can be reached at his consulting office at (217) 586-4683.
Contents at a Glance
Contents
Preface
C++ is the preeminent language for the development of high-performance software. It is also the language that defines the modern syntax and style that have influenced all subsequent languages. For example, both Java and C# are descended from C++. Moreover, C++ is the universal language of programming, in which nearly all professional programmers have at least passing competency. By learning C++, you will be establishing a solid foundation that will enable you to pursue any aspect of programming today.
The purpose of this book is to teach you the fundamentals of C++ programming. It uses a step-by-step approach complete with numerous examples, self-tests, and projects. It assumes no previous programming experience. The book starts with the basics, such as how to compile and run a C++ program. It then discusses the keywords, features, and constructs that comprise the C++ language. By the time you finish, you will have a firm grasp of the essentials of C++ programming.
It is important to state at the outset that this book is just a starting point. C++ is a large, sophisticated language, and successful C++ programming involves more than just the keywords, operators, and syntax that define the language. It also involves the use of an extensive set of class and function libraries that aid in the development of programs. Although several of the library elements are discussed in this book, because of space limitations, most are not. To be a top-notch C++ programmer implies mastery of C++ libraries, too. After completing this book, you will have the knowledge to explore the libraries and all other aspects of C++.
How This Book Is Organized
This book presents an evenly paced tutorial in which each section builds upon the previous one. It contains 12 modules, each discussing an aspect of C++. This book is unique because it includes several special elements that reinforce what you are learning.
Critical Skills
Each module begins with a set of critical skills that tell you what you will be learning. The location of each skill is indicated within the module.
Mastery Check
Each module concludes with a Mastery Check, a self-test that lets you test your knowledge. The answers are found on the Web at this books page at www.osborne.com.
Progress Checks
At the end of each major section is a Progress Check that tests your understanding of the key points that were presented. The answers to these questions are at the bottom of the page.
Ask the Expert
Sprinkled throughout the book are special Ask the Expert boxes. These contain additional information or interesting commentary about a topic. They use a Question/Answer format.
Projects
Each module contains one or more projects that show you how to apply what you are learning. These are real-world examples that you can use as starting points for your own programs.
No Previous Programming Experience Required
This book assumes no previous programming experience. Thus, if you have never programmed before, you can use this book. Of course, in this day and age, most readers will have at least a little prior programming experience. For many, this previous experience will be in Java or C#. As you will learn, C++ is the parent of both of these languages. Therefore, if you already know Java or C#, then you will be able to learn C++ easily.