473,326 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

extraction operator

Hi all,

Jesse Liberty writes:

"cin.get() >>myVarOne >myVarTwo; // illegal

The return value of (cin.get() >myVarOne) is an integer, not an
iostream object."

(http://newdata.box.sk/bx/c/htm/ch16.htm)

I would think that that the reason why this wouldn't work is because
cin.get() returns an int, not because (cin.get() >mVarOne) is an
integer...

Anyone agree?

Taras
Jun 27 '08 #1
5 2101

"Taras_96" <ta******@gmail.comwrote in message
Hi all,

Jesse Liberty writes:

"cin.get() >>myVarOne >myVarTwo; // illegal

The return value of (cin.get() >myVarOne) is an integer, not an
iostream object."

(http://newdata.box.sk/bx/c/htm/ch16.htm)

I would think that that the reason why this wouldn't work is because
cin.get() returns an int, not because (cin.get() >mVarOne) is an
integer...
Anyone agree?
If mVarOne is an integral type then (cin.get() >mVarOne) would return an
integer. The code won't even compile if mVarOne has any other type.

--
http://techytalk.googlepages.com
Jun 27 '08 #2
On Apr 30, 6:21 am, Taras_96 <taras...@gmail.comwrote:
Hi all,

Jesse Liberty writes:

"cin.get() >>myVarOne >myVarTwo; // illegal

The return value of (cin.get() >myVarOne) is an integer, not an
iostream object."
The author probably means that "it will not work the way one might
expect." It is illegal only if myVarOne or myVarTwo is uninitialized.
(I don't remember whether the values must be less than or equal to the
total bits in 'int'.)

cin.get() >myVarOne

is the result of an int shifted right by the value of myVarOne

/* ... */ >myVarTwo

is further shifting the result of the previous operation right some
more.
>
(http://newdata.box.sk/bx/c/htm/ch16.htm)

I would think that that the reason why this wouldn't work is because
cin.get() returns an int, not because (cin.get() >mVarOne) is an
integer...
The code should compile and work in that possibly unexpected way.

Ali
Jun 27 '08 #3
<ac******@gmail.comwrote in message
On Apr 30, 6:21 am, Taras_96 <taras...@gmail.comwrote:
>Hi all,

Jesse Liberty writes:

"cin.get() >>myVarOne >myVarTwo; // illegal

The return value of (cin.get() >myVarOne) is an integer, not an
iostream object."

The author probably means that "it will not work the way one might
expect." It is illegal only if myVarOne or myVarTwo is uninitialized.
(I don't remember whether the values must be less than or equal to the
total bits in 'int'.)
I think (after looking at the link provided by OP) probably the author means
that this code won't work the way "cin >mVar1 >mVar2" would have worked.

<Quote from link>
When you write cin >VarOne >varTwo >varThree;, the first extraction is
evaluated (cin >VarOne). The return value from this is another istream
object, and that object's extraction operator gets the variable varTwo. It
is as if you had written this: ((cin >varOne) >varTwo) >varThree;
</Quote from link>

--
http://techytalk.googlepages.com
Jun 27 '08 #4
On Apr 30, 3:21 pm, Taras_96 <taras...@gmail.comwrote:
Jesse Liberty writes:
"cin.get() >>myVarOne >myVarTwo; // illegal
The return value of (cin.get() >myVarOne) is an integer, not
an iostream object."
(http://newdata.box.sk/bx/c/htm/ch16.htm)
I would think that that the reason why this wouldn't work is
because cin.get() returns an int, not because (cin.get() >>
mVarOne) is an integer...
Anyone agree?
As others have pointed out, 1) it's not illegal (since myVarOne
and myVarTwo have type char), but 2) it almost certainly doesn't
mean what you want.

I might add in general that, having taken a quick look at the
page, it seems full of errors. I didn't read it in detail, but
of the four or five sentences I did notice, about have were
wrong. I don't think I'd recommend this text.

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 27 '08 #5
Thanks everyone - I didn't even think of the shift operator :)

Taras
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kangol kangoll | last post by:
hi, i've been trying to figure out how to make visual basic start extracting text at a certain line to when i tell it to stop. I am making trying to make a program where it extracts text from a...
7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
0
by: Howell, Scott | last post by:
I am looking for a simple extraction/load program to load data daily from a Progress 8.3B database via ODBC to a mysql 3.23.57 database. It does not necessarily need to do any data-type...
2
by: Jason Huang | last post by:
Hi, Would someone show me how to do the data extraction to Excel in ASP.Net using C# web form? I am not familiar with VB, so I am asking someone to help me out! Any help will be appreciated. ...
1
by: yeutim | last post by:
I can't find anything wrong this with this class. Especially, Overloading Stream-Extraction Operator (in blue). Any one know what do I need to fix this problem please reply. Thank you for your...
1
by: James Lehman | last post by:
Hello. I want to write a program that reads AutoCAD shape (font) files. They are written with the convention that hexadecimal values have a leading zero and decimal values do not. All numbers...
3
by: dec01louis | last post by:
Hi all, actually i'm now doing something on license plate recognition system for my project. The first step would be the license plate extraction algorithm which means it is needed to extract a...
16
by: EM.Bateman | last post by:
Working on Visual Studio .Net I've implemented a class: #ifndef CONTRIBUTOR_H #define CONTRIBUTOR_H enum Gender {male=1, female, unk}; #include <iostream> #include <iomanip> #include...
5
by: newbarker | last post by:
Hello all, #include <sstream> #include <iostream> int main() { std::istringstream iss("6.5e"); double size; char fit;
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.