A Beginner's Guide to C++

Only available on StudyMode
  • Download(s) : 88
  • Published : April 23, 2013
Open Document
Text Preview
C++ Without Fear
Second Edition

This page intentionally left blank

C++ Without Fear
Second Edition
A Beginner’s Guide That Makes You Feel Smart

Brian Overland

Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein. The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests. For more information, please contact: U.S. Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United States please contact: International Sales international@pearson.com Visit us on the Web: informit.com/ph Library of Congress Cataloging-in-Publication Data Overland, Brian R. C++ without fear : a beginner's guide that makes you feel smart / Brian Overland.—2nd ed. p. cm. Includes index. ISBN 978-0-13-267326-6 (pbk. : alk. paper) 1. C++ (Computer program language) I. Title. QA76.73.C153O838 2011 005.13'3—dc22 2011004218 Copyright © 2011 Pearson Education, Inc. All rights reserved. Printed in the United States of America. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, write to: Pearson Education, Inc. Rights and Contracts Department 501 Boylston Street, Suite 900 Boston, MA 02116 Fax: (617) 671-3447 ISBN-13: 978-0-13-267326-6 ISBN-10: 0-13-267326-6 Text printed in the United States on recycled paper at Edwards Brothers in Ann Arbor, Michigan. First printing, April 2011

For Colin

This page intentionally left blank

About This Book: How It’s Different Onward to the Second Edition “Where Do I Begin?” Icons, Icons, Who’s Got the Icons? What Is Not Covered? Getting Started with C++: A Free Compiler A Final Note: Have Fun! xxiii xxiii xxiv xxv xxv xxvi xxvii xxvii xxix xxxi

Acknowledgments About the Author
Chapter 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)

1 1 1 1 2 4 4 7 8 8 8




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 Chapter 1 Summary Chapter 2

9 9 10 11 12 12...
tracking img