C++ Teach Yourself
Sams Teach Yourself
C++
24 Hours
in
800 East 96th Street, Indianapolis, Indiana, 46240 USA
Sams Teach Yourself C++ in 24 Hours
Copyright © 2011 by Pearson Education, Inc. All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, orotherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein.ISBN-13: 978-0-672-33331-6 ISBN-10: 0-672-33331-7 Printed in the United States of America First Printing April 2011 Library of Congress Cataloging-in-Publication data is on file.
Editor in Chief Mark Taub Acquisitions Editor Mark Taber Development Editor Songlin Qiu Managing Editor Sandra Schroeder Project Editor Mandie Frank Copy Editor Keith Cline Indexer Lisa Stumpf Proofreader LeslieJoseph Technical Editor Jon Upchurch Publishing Coordinator Vanessa Evans Media Producer Dan Scherf Designer Gary Adair Compositor Mark Shirar
Trademarks
All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded asaffecting the validity of any trademark or service mark.
Warning and Disclaimer
Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an “as is” basis. The authors and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arisingfrom the information contained in this book or from the use of the CD or programs accompanying it.
Bulk Sales
Sams Publishing offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales. For more information, please contact U.S. Corporate and Government Sales 1-800-382-3419 corpsales@pearsontechgroup.com For sales outside of the U.S., please contactInternational Sales international@pearsoned.com
Table of Contents
Introduction Part I: Beginning C++
HOUR 1: Writing Your First Program Using C++ .
1
5
.................................................................................................................................................................. 5
Finding a Compiler .............................................................................................................................................. 6 Compiling and Linking the Source Code Creating Your First Program
. ....................................................................................... 9
. .................................................................................................................... 10
HOUR 2:Organizing the Parts of a Program
15
Reasons to Use C++ . ......................................................................................................................................... 15 The Parts of a Program
. .............................................................................................................................. 19
Comments ................................................................................................................................................................ 22 Functions
. ............................................................................................................................................................... 23
HOUR 3: Creating Variables and Constants
29
What Is a Variable? ....
Regístrate para leer el documento completo.