正在加载图片...
9 18. A Simple Program: Adding Two Integers(Cont) Declarations can be placed almost anywhere in a C++ program They must appear before their corresponding variables are used in the program Input stream object std:: cin from <iostream> Usually connected to keyboard Stream extraction operator >> Waits for user to input value, press Enter(Return) key Stores value in varia ble to the right of operator Converts value to variable data type · Example std: :cin > number 1: Reads an integer typed at the keyboard Stores the integer in variable number1 Just like scanf(%d",&number1) in C o 2007 Pearson Education, Inc. All rights reserved© 2007 Pearson Education, Inc. All rights reserved. 9 18.3 A Simple Program: Adding Two Integers (Cont.) • Declarations can be placed almost anywhere in a C++ program – They must appear before their corresponding variables are used in the program • Input stream object – std::cin from <iostream> • Usually connected to keyboard • Stream extraction operator >> - Waits for user to input value, press Enter (Return) key - Stores value in variable to the right of operator • Converts value to variable data type • Example - std::cin >> number1; • Reads an integer typed at the keyboard • Stores the integer in variable number1 - Just like scanf(“%d”, &number1) in C
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有