11.3 FORMAT-FREE INPUT

Let us study it in terms of various basic data types.

(1) Reading Integers

In C++, cin is the standard stream object for input. It is usually associated with the keyboard. The binary extraction operator >> is used for reading (input). Some books call it input operator. It takes cin as left-hand-side operand and a variable to be read as right-hand-side operand. A statement like

cin >> marks ;

reads marks for us. It is like scanf(“%d”, &marks) ; This statement1 does the following: it tells the computer to read the value of marks from stream cin. Note the ease of operations compared to old C language. We do not have to specify or tell that variable “marks” is an integer. We do not need ‘&’operator around marks. When you execute ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.