《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 1 C++ Basics

Chapter 1 ABSOLUTE C++ C++Basics WALTER SAVITCH SECOND EDITION PEARSON Copyright2006 Pearson Addison-Wesley.All rights reserved
Chapter 1 C++ Basics

Learning Objectives ◆Introduction to C++ Origins,Object-Oriented Programming,Terms Variables,Expressions,and Assignment Statements Console Input/Output ◆Program Style Libraries and Namespaces Copyright2006 Pears on Addison-Wesley.All rights reserved. 1-2
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-2 Learning Objectives Introduction to C++ Origins, Object-Oriented Programming, Terms Variables, Expressions, and Assignment Statements Console Input/Output Program Style Libraries and Namespaces

Introduction to C++ ◆C++Origins ◆Low-level languages ◆Machine,assembly High-level languages +C,C++,ADA,COBOL,FORTRAN Object-Oriented-Programming in C++ ◆Ct+Terminology Programs and functions Basic Input/Output(1/O)with cin and cout Copyright2006 Pears on Addison-Wesley.All rights reserved. 1-3
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-3 Introduction to C++ C++ Origins Low-level languages Machine, assembly High-level languages C, C++, ADA, COBOL, FORTRAN Object-Oriented-Programming in C++ C++ Terminology Programs and functions Basic Input/Output (I/O) with cin and cout

Display 1.1 A Sample C++Program(1 of 2) Display 1.A Sample C++Program 1 #include 2 using namespace std; 3 int main() 4 int numberOfLanguages; 6 cout numberOfLanguages; 10 if (numberofLanguages 1) 11 cout <"Read the preface.You may prefer\n" 2 <<"a more elementary book by the same author.\n"; 13 else 14 cout <"Enjoy the book.\n"; 15 return 0; 163 Copyright2006 Pears on Addison-Wesley.All rights reserved. 1-4
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-4 Display 1.1 A Sample C++ Program (1 of 2)

Display 1.1 A Sample C++Program(2 of 2) SAMPLE DIALOGUE I Hello reader. Welcome to C++. How many programming languages have you used?0-User types in 0 on the keyboard. Read the preface.You may prefer a more elementary book by the same author. SAMPLE DIALOGUE 2 Hello reader. Welcome to C++. How many programming languages have you used?1-User types in 1 on the keyboard. Enjoy the book Copyright 2006 Pearson Addison-Wesley.All rights reserved. 1-5
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-5 Display 1.1 A Sample C++ Program (2 of 2)

C++Variables ◆C++ldentifiers Keywords/reserved words vs.Identifiers Case-sensitivity and validity of identifiers ◆Meaningful names! ◆Variables A memory location to store data for a program Must declare all data before use in program Copyright006 Pearson Addison-Wesley.All rights reserved. 1-6
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-6 C++ Variables C++ Identifiers Keywords/reserved words vs. Identifiers Case-sensitivity and validity of identifiers Meaningful names! Variables A memory location to store data for a program Must declare all data before use in program

Data Types: Display 1.2 Simple Types (1 of 2) Display 1.2 Simple Types TYPE NAME MEMORY USED SIZE RANGE PRECISION short 2 bytes -32,767t032,767 Not applicable (also called short int) int 4 bytes -2,147,483,647t0 Not applicable 2,147,483,647 long 4bytes -2,147,483,647t0 Not applicable (also called 2,147,483,647 long int) float 4bytes approximately 7 digits 1038to1o38 double 8 bytes approximately 15 digits 103o8to103o8 Copyright 2006 Pearson Addison-Wesley.All rights reserved. 1-7
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-7 Data Types: Display 1.2 Simple Types (1 of 2)

Data Types: Display 1.2 Simple Types(2 of 2) long double io bytes approximately 9digits 104932t0104932 char I byte All ASCII characters Not applicable (Can also be used as an integer type, although we do not recommend doing s0.) bool i byte true,false Not applicable The values listed here are only sample values to give you a general idea of how the types differ. The values for any of these entries may be different on your system.Precision refers to the num- ber of meaningful digits,including digits in front of the decimal point.The ranges for the types float,double,and Long double are the ranges for positive numbers.Negative numbers have a similar range,but with a negative sign in front of each number. Copyright2006 Pears on Addison-Wesley.All rights reserved. 1-8
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-8 Data Types: Display 1.2 Simple Types (2 of 2)

Assigning Data Initializing data in declaration statement Results "undefined"if you don't! ◆int myValue=O; Assigning data during execution Lvalues (left-side)&Rvalues (right-side) Lvalues must be variables Rvalues can be any expression ◆Example: distance rate time; Lvalue:"distance" Rvalue:"rate time" Copyright 2006 Pearson Addison-Wesley.All rights reserved. 1-9
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-9 Assigning Data Initializing data in declaration statement Results "undefined" if you don’t! int myValue = 0; Assigning data during execution Lvalues (left-side) & Rvalues (right-side) Lvalues must be variables Rvalues can be any expression Example: distance = rate * time; Lvalue: "distance" Rvalue: "rate * time

Assigning Data:Shorthand Notations ◆Display,page14 EXAMPLE EQUIVALENT TO count +=2; countcount +2; total-=discount; total total-discount; bonus *=2; bonus bonus 2; time /rushFactor; time time/rushFactor; change %100; change change 100; amount *cntl +cnt2; amount amount (cntl cnt2); Copyright2006 Pears on Addison-Wesley.All rights reserved. 1-10
Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 1-10 Assigning Data: Shorthand Notations Display, page 14
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 4 Parameters and Overloading.ppt
- 西安邮电大学:《信息论与编码》课程教学课件(PPT讲稿)第三章.ppt
- 西安邮电大学:《信息论与编码》课程教学课件(PPT讲稿)第二章 信源与信息熵.ppt
- 西安邮电大学:《信息论与编码》课程教学课件(PPT讲稿)第一章 绪论(主讲:王军选).ppt
- 《信息论与编码》课程教学资源(作业习题)第三章 信道与信道容量(含解答).pdf
- 《信息论与编码》课程教学资源(作业习题)自测题无答案.pdf
- 《信息论与编码》课程教学实验指导书.pdf
- 《信息论与编码》课程教学大纲 Element of Information Theory and Coding B.pdf
- 《信息论与编码》课程教学大纲 Element of Information Theory and Coding A.pdf
- 《信息安全概论》课程教学资源(PPT课件)第9章 信息安全标准与法律法规.ppt
- 《信息安全概论》课程教学资源(PPT课件)第2章 信息保密技术.ppt
- 《信息安全概论》课程教学资源(PPT课件)第7章 网络安全技术.ppt
- 《信息安全概论》课程教学资源(PPT课件)第8章 信息安全管理.ppt
- 《信息安全概论》课程教学资源(PPT课件)第6章 访问控制技术.ppt
- 《信息安全概论》课程教学资源(PPT课件)第5章 操作系统与数据库安全.ppt
- 《信息安全概论》课程教学资源(PPT课件)第1章 绪论.ppt
- 《信息安全概论》课程教学资源(PPT课件)第3章 信息认证技术.ppt
- 《信息安全概论》课程教学资源(PPT课件)第4章 信息隐藏技术.ppt
- 西安邮电大学:《信息安全概论》课程教学资源(教材书籍,共九章,人民邮电出版社,主编:张雪峰).pdf
- 西安邮电大学:《信息安全概论》课程教学大纲 Introduction to Information Security.doc
- 《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 3 Function Basics.ppt
- 《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 2 Flow of Control.ppt
- 《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 6 Structures and Classes.ppt
- 《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 7 Constructors and Other Tools.ppt
- 《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 8 Operator Overloading, Friends, and References.ppt
- 《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 5 Arrays.ppt
- 《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 11 Separate Compilation and Namespaces.ppt
- 《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 12 Streams and File IO.ppt
- 《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 10 Pointers and Dynamic Arrays.ppt
- 《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 9 Strings.ppt
- 《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 13 Inheritance.ppt
- 《C++面向对象程序设计》课程教学资源(PPT课件)Chapter 14 Polymorphism and Virtual Functions.ppt
- 《微机技术及应用》课程教学大纲 Microcmputer Technology and aplications.doc
- 《微型计算机技术及应用》课程电子教案(PPT教学课件,共十五章,完整版).pptx
- 《计算机导论》课程教学大纲 Computer Concepts.pdf
- 《计算机导论》课程教学课件(英文讲稿)1-a-Computer History+ Di Devices.pdf
- 《计算机导论》课程教学课件(英文讲稿)1-b-Digital Data Representation.pdf
- 《计算机导论》课程教学课件(英文讲稿)2-a-Computer Hardware.pdf
- 《计算机导论》课程教学课件(英文讲稿)2-b-Computer Hardware.pdf
- 《计算机导论》课程教学课件(英文讲稿)3-a-b-Computer Software.pdf