2074 Introduction To C Plus Plus PDF

March 6, 2023 | Author: Anonymous | Category: N/A
Share Embed Donate


Short Description

Download 2074 Introduction To C Plus Plus PDF...

Description

Science & Mathematics

Introduction to C++ Programming Concepts and Applications Professor John Keyser

Technology 

Published by 

THE GREAT GR EAT CO COURSES URSES

Corporate Headquarters 4840 Westfields Boulevard | Suite 500 | Chantilly, Virginia | 20151-2299 [󰁰󰁨󰁯󰁮󰁥] [󰁰󰁨󰁯󰁮󰁥] 1.800.832.2412  1.800.832.2412 | [󰁦󰁡󰁸] [󰁦󰁡󰁸] 703.378.3819  703.378.3819 | [󰁷󰁥󰁢]  [󰁷󰁥󰁢] www.thegreatcourses  www.thegreatcourses.com .com

Copyright © The Teaching Company, 2019 Printed in the United States of America  This book is in copyright. All rights reserved. Without limiting the rights under copyright reserved above, no part of this publication may be reproduced, stored in or introduced into a retrieval system, or transmitted, in any form, or by any means (electronic, mechanical, photocopying, recording, or otherwise), without the prior written permission of The Teaching Company.

John Keyser, PhD Professor of Computer Science and Engineering Texas A&M University John Keyser is a Professor of Computer Science and Engineering at Texas A&M University.. He earned his PhD in Computer University Science from the University of North Carolina. Carolina .  As an undergraduate, undergraduate, he earned 3 bachelor's degrees—in Computer Science, Science, Engineering

of biological data, data, reconstructing the geometric structures in that data, data , and helping visualize the results in effective ways. ways . In addition,, he has published papers on a variety addition of other graphics topics, topics , including rendering and modeling. modeling.

Physics,, and Applied Math—from Physics Math—from Abilene Christian University. University.  Professor Keyser's interests in physics, physics,  math,, and computing led him to a career in math computer graphics, graphics, which has allowed him to combine all 3 disciplines. disciplines . He has published several articles in geometric modeling modeling,,  particularly looking at ways of quantifying and eliminating uncertainty in geometric calculations . Professor Keyser has been a longcalculations. standing member of the solid and physical modeling community, community, including previously serving on the Solid Modeling Associatio Association n executive committee. committee. He has also published several articles and coauthored a textbook in physically based simulation for graphics (Foundations of Physically Based Modeling and Animation) Animation). As a member of the Brain Networks Laboratory collaboration at Texas A&M,, he has worked on developing A&M developing a new technique techniq ue for rapidly scanning vast amounts

Professor Keyser's teaching has spanned a range of courses, courses, from introductory undergraduate courses in programming; programming;  through upper-level undergraduate courses in graphics, graphics, programming  programming,, and software development;; to graduate courses in graphics development modeling and simulation. simulation. Among these, these, he created a course called Programming Studio

Excellence , and he has received other awards, Excellence, awards,  including the Tenneco Meritorious Teaching Award and the Theta Tau Most Informative Lecturer Award. Award. 

that has become required for all Computer

Since writing his first computer program more

Science and Computer Engineering majors at Texas A&M, A&M, and he helped develop the introductory programming course taught to all Texas A&M Engineering students. students.  Professor Keyser has won several teaching awards at Texas A&M, A&M, including the Distinguished Achievement Award in Teaching, Teaching, 

than 35 years ago, ago, Professor Keyser has loved computer programming. programming. He has particularly enjoyed programming competitions, competitions, both as a student competitor and as a team coach. coach. Of the many computer science classes he took, took,  the most important class turned out to be the one in which he met his wife. wife. In his free time, time, he enjoys traveling with her and their 2 daughters . 

which he received once at the university level and twice from the College of Engineering. Engineering.  As an assistant prof professor essor,, he was named a Montague Scholar by the Center for Teaching

Professor Keyser's other Great Course is How to Program: Computer Science Concepts and Python Exercises. Exercises. 

i

Professor Biography

Table of Contents Professor Biography ......................... ............. i

03

Boolean Variables  31

Course Scope .......................... .................. 1

01

Comparison Operators  34 Conditional Statements  35 Quiz  42

Compiling Your First C++ Program  .................... 2 Introduction to Computer Programming   2

Quiz Answers  43

What Happens When You Program  3 Your First Program  4

04

Quiz  8

Designing and Testing Your Program   46 Quiz  52

01b C++ QUICK START: With Browser or Download  ....... 10

Quiz Answers  53

Introduction  10 Quick Start with a Browser  11

05

Quick Start with an IDE  14

Variables, Computations, and Input in C++ ........... 17

Quiz  63

Variable Declarations  19

Quiz Answers  64

Variable Assignments  21 Incrementing Variables  23 How C++ Supports Mathematical Functions  25 Input  26 Quiz  29 Quiz Answers  30

C++ Loops and Iteration .......................... .......................... ... 54 While Loops  54 For Loops  57 Scope of Variables  61

Variables and Computations  17

Computing Calories  22

Program Design and Writing Test Cases in C++  ....... 44 The Structure of a C++ Program   44

Quiz Answers  9

02

Booleans and Conditionals in C++  ................... 31

06

Importing C++ Functions and Libraries ............... 65 Code Libraries  65 How Code and Libraries Are Compiled in C++  66 The C++ Standard Library   67 Random Numbers  69 Quiz  74 Quiz Answers  75

NAVIGATION TIP

To go back to the page you came from, press Alt +

← on a PC or ⌘ + ← on a Mac. On a tablet, use the bookmarks panel.

ii

Table of Contents

07

Arrays for Quick and Easy Data Storage ............. 76

12

Functions as Black Boxes   131

Indexing into an Array   78

Creating Your Own Functions  132

Initializing an Array  81

The Function Body  134

Array Bounds  83

Conceptual Separation  135

Quiz  84

Scope  138 Quiz  14 142 2

Quiz Answers  85

08

Expanding What Your Functions Can Do in C++  ..... 144 Overloading Functions  144

Vector Resizing  91

Setting Default Parameters  148

Performing Out-of-Bounds Checks  92

Using References  149

Assigning Vectors  94

Quiz  152

Quiz  95

Quiz Answers  153

14

C++ Strings for Manipulating Text .................... 98

Systematic Debugging, Writing Exceptions .......... 154 A Systematic Approach to Debugging  154

String Variables and Literals  98

Types and Sources of Errors  159

String Operations  102

Using Exceptions  160

Char-Type Variables  103

Quiz  163

Quiz  107

Quiz Answers  164

Quiz Answers  108

11

13

Vector Size Initialization  89

Quiz Answers  96

10

Quiz Answers  143

Vectors for Safe and Flexible Data Storage  ........... 86 Using Vectors  86

09

Creating Your Own Functions in C++ ................ 131

Variables in Memo ry   76 Storing Variables

15

Files and Stream Operators in C++ .................. 109

165 Functions in Top-Down and Bottom-Up Design ..... 165 Top-Down Design  165

File Streaming  109

Bottom-Up Design  169

String Streaming  113

Building a Library   17 171 1

Quiz  116

Quiz  17 173 3

Quiz Answers  11 117 7

Quiz Answers  17 174 4

Top-Down Design and Using a C++ Debugger  ....... 119

16

Objects and Classes: Encapsulation in C++  .......... 175

Top-Down Design  119

Object-Oriented Programming  17 175 5

Incremental Development  122

Creating Classes  17 177 7

Debugger Tool  124

Sorting Data in Classes   17 177 7

Quiz  128

Public versus Private  181

Quiz Answers  129

Quiz  185 Quiz Answers  186

Table of Contents

iii ii i

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF