John smiley learn to program with c++ 2003

625 582 0
John smiley   learn to program with c++ 2003

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Đây là quyển sách tiếng anh về lĩnh vực công nghệ thông tin cho sinh viên và những ai có đam mê. Quyển sách này trình về lý thuyết ,phương pháp lập trình cho ngôn ngữ C và C++.

TLFeBOOK with C++ LearnTo / Learn to Program with C++ / Smiley / 222535-1 / Front Matter Blind Folio FM:i LearnTo / Learn to Program with C++ / Smiley / 222535-1 / Front Matter Blind Folio FM:i P:\010Comp\LearnTo\535-1\FM.vp Tuesday, October 08, 2002 9:42:27 PM Color profile: Generic CMYK printer profile Composite Default screen http://avaxho.me/blogs/ChrisRedfield This page intentionally left blank. TLFeBOOK with C++ John Smiley McGraw-Hill/Osborne New York Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi San Juan Seoul Singapore Sydney Toronto LearnTo / Learn to Program with C++ / Smiley / 222535-1 / Front Matter Blind Folio FM:iii P:\010Comp\LearnTo\535-1\FM.vp Tuesday, October 08, 2002 9:42:27 PM Color profile: Generic CMYK printer profile Composite Default screen TLFeBOOK Copyright © 2003 by The McGraw-Hill Companies, Inc.]. All rights reserved. Manufactured in the United States of America. 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. 0-07-223040-1 The material in this eBook also appears in the print version of this title: 0-07-222535-1 All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occur- rence 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. For more information, please contact George Hoare, Special Sales, at george_hoare@mcgraw-hill.com or (212) 904-4069. 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-Hill’s 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 WAR- RANTY, 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 cir- cumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, conse- quential 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 whatso- ever whether such claim or cause arises in contract, tort or otherwise. DOI: 10.1036/0072230401 ebook_copyright 7.5x9.qxd 7/8/03 8:54 AM Page 1 TLFeBOOK This book is dedicated to my wife, Linda. LearnTo / Learn to Program with C++ / Smiley / 222535-1 / Front Matter Blind Folio FM:v P:\010Comp\LearnTo\535-1\FM.vp Tuesday, October 08, 2002 9:42:27 PM Color profile: Generic CMYK printer profile Composite Default screen TLFeBOOK LearnTo / Learn to Program with C++ / Smiley / 222535-1 / Front Matter Blind Folio FM:vi About the Author John Smiley, a Microsoft Certified Professional (MCP) and Microsoft Certified Solutions Developer (MCSD) in Visual Basic, has been programming and teaching for more than 20 years. He is the President of John Smiley and Associates, a computer consulting firm serving clients both large and small in the Philadelphia metropolitan area. John is an adjunct professor of Computer Science at Penn State University, Philadelphia University, and Holy Family College, and also teaches in a variety of Internet venues, including SmartPlanet and ElementK. On the writing front, John is the author of the immensely popular Learn to Program with Visual Basic 6, along with Learn to Program with Visual Basic Examples, Learn to Program Databases with Visual Basic 6, Learn to Program Objects with Visual Basic 6, Learn to Program with Java, Learn with Program with Visual Basic .NET, and Learn to Program with C#. He has also done technical editing on a number of Visual Basic titles for Wrox and Que, in addition to being a popular guest on TechTV’s ScreenSavers program. Feel free to visit John’s website at www.johnsmiley.com or contact him via e-mail at johnsmiley@johnsmiley.com. He religiously answers all his e-mails, although not necessarily instantaneously! P:\010Comp\LearnTo\535-1\FM.vp Tuesday, October 08, 2002 9:42:27 PM Color profile: Generic CMYK printer profile Composite Default screen TLFeBOOK Contents at a Glance 1 Where Do I Begin? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 Getting Comfortable with C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 3 Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 4 Selection Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 5 Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 6 Creating Your Own Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231 7 Creating Objects from Instantiable Classes . . . . . . . . . . . . . . . . . . . . . . . . 285 8 Controlling Access to the Data in Your Object . . . . . . . . . . . . . . . . . . . . . 347 9 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 10 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 439 11 Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 485 12 Errors and Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589 vii LearnTo / Learn to Program with C++ / Smiley / 222535-1 / Front Matter P:\010Comp\LearnTo\535-1\FM.vp Tuesday, October 08, 2002 9:42:27 PM Color profile: Generic CMYK printer profile Composite Default screen Copyright 2003 by The McGraw-Hill Companies, Inc. Click Here for Terms of Use. For more information about this title, click here. TLFeBOOK This page intentionally left blank. TLFeBOOK Contents Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv 1 Where Do I Begin? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Where Do I Begin? · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 2 Programming the Easy Way · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 3 Planning a Program Is Like Planning a House . . . . . . . . . . . . . . . 4 We Receive a Call from Our “Client” . . . . . . . . . . . . . . . . . . . . . . 5 We Meet with Our Client . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 The Systems Development Life Cycle (SDLC) · · · · · · · · · · · · · · · · · · · · · 9 Phase 1: The Preliminary Investigation . . . . . . . . . . . . . . . . . . . . . 12 Phase 2: Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Phase 3: Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Phase 4: Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 Phase 5: Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Phase 6: Audit and Maintenance . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Where to from Here? · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 37 Summary · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 38 2 Getting Comfortable with C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Sit Down and Get Cozy with C++ · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 40 Writing Our First C++ Program . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Elements of a C++ Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 Summary · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 64 3 Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Computer Data · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 66 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 C++ Data Types · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · · 84 Numeric Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 Nonnumeric Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 ix LearnTo / Learn to Program with C++ / Smiley / 222535-1 / Front Matter P:\010Comp\LearnTo\535-1\FM.vp Tuesday, October 08, 2002 9:42:27 PM Color profile: Generic CMYK printer profile Composite Default screen For more information about this title, click here. Copyright 2003 by The McGraw-Hill Companies, Inc. Click Here for Terms of Use. TLFeBOOK [...]... down to the reader—my books make it “OK” and even fun to be a real beginner learning to program Who the Book Is For This book presumes you have absolutely no programming experience If that’s you, and you want to learn how to write a computer program using what can be a very difficult language to learn, C++, then this book is definitely for you If you have some programming experience and want to learn. .. down with the prospective user of their system to determine what is required to satisfy the user’s needs That skill to listen to the user and determine their needs—is something that I now teach to some extent in all my computer classes, whether they are programming courses, courses on systems analysis and design, or courses on database management TLFeBOOK 4 Learn to Program with C++ Planning a Program. .. Introduction to Programming with C++ class for the first time For the last few semesters, my university has been using both Visual Basic and C++ as the introductory programming languages Probably nothing is as easy as Visual Basic to learn, and probably nothing is as flexible and platform independent as C++ As is my custom during my first class, I took roll and asked each of the students to write a brief... Frank Olley told us what he wanted the program to do Like any client, he described his program requirements in functional terms that he understood My students were already familiar with computer applications, but at this point in our course, they were not C++ experts and their programming knowledge was not sufficient for them to know how to translate Frank Olley’s requirements into C++ programming... Joe, John. ” “Jack, if you don’t mind.” “Barbara, Kathy, Dave, Ward, Blaine, Kate, Mary, Chuck, Lou, Bob.” That makes 18 students TLFeBOOK 10 Learn to Program with C++ After giving them 15 minutes to write, I collected their biographies and began to read them A few had some programming experience using languages that were a bit dated A number were looking to get into the exciting world of computer programming,... the following e-mail Hi Frank, I want to thank you for taking the time to meet with me last Tuesday afternoon As I discussed with you at that time, it is my desire to work with you in developing a program that can calculate student grades for the English, Math, and Science departments The program will be developed as part of my Introduction to Programming with C++ computer class at the university As... contractor and homebuilder His job is similar to that of a programmer or system designer He recently built an addition to a customer’s house He wouldn’t think of beginning that work without first meeting with the owners of the house to determine their needs He couldn’t possibly presume to know what the owners want or need The builder’s role, in meeting with the owners, is largely to listen and then to. .. experience and want to learn how to program in C++, this book is also for you Experienced programmers tell me that my thorough, methodical method of teaching works for them as well xv Copyright 2003 by The McGraw-Hill Companies, Inc Click Here for Terms of Use TLFeBOOK xvi Learn to Program with C++ Either way, as one of my readers wrote me, my books make it OK not to understand something the first... that we have gathered enough information in Phase 1 of the SDLC to begin programming, the SDLC dictates that Phase 2 be completed before the actual writing of the program begins TLFeBOOK 14 Learn to Program with C++ “The biggest mistake we could make at this point would be to begin coding the program Why is that? As we’ll see shortly, we need to gather more information about the business from the ‘owners’—in... finish the program by the end of the spring semester, we can use the program to calculate the grades in each of our departments Of course, I’m guessing that the program your students write won’t be as sophisticated as one that you would write After all, your students are just beginners.” TLFeBOOK 8 Learn to Program with C++ To some degree that’s true, Frank,” I said “Most notably, the program we produce . TLFeBOOK with C++ LearnTo / Learn to Program with C++ / Smiley / 22253 5-1 / Front Matter Blind Folio FM:i LearnTo / Learn to Program with C++ / Smiley / 22253 5-1 . us to be together again. xiv Learn to Program with C++ LearnTo / Learn to Program with C++ / Smiley / 22253 5-1 / Front Matter P:10CompLearnTo53 5-1 FM.vp Tuesday,

Ngày đăng: 19/03/2014, 14:10

Từ khóa liên quan

Mục lục

  • Learn.To.Program.With.C++

    • Cover

    • About the Author

    • Contents at a Glance

    • Contents

    • Acknowledgments

    • Introduction

    • Chapter 1 Where Do I Begin?

    • Chapter 2 Getting Comfortable with C++

    • Chapter 3 Data

    • Chapter 4 Selection Structures

    • Chapter 5 Loops

    • Chapter 6 Creating Your Own Functions

    • Chapter 7 Creating Objects from Instantiable Classes

    • Chapter 8 Controlling Access to the Data in Your Object

    • Chapter 9 Inheritance

    • Chapter 10 Arrays

    • Chapter 11 Pointers

    • Chapter 12 Errors and Error Handling

    • INDEX

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan