flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > what in c++ std::cin>>somethin; take?

Author
Thread Post new topic Reply to topic
äüöu



Joined: 21 Apr 2014
Posts: 1
äüöu 21 Apr 2014, 18:25
i have a qest for you:
find out what in c++
std::cin>>somethin;
take and why its a bit shift operator >>?

thanx y0u advice.
Post 21 Apr 2014, 18:25
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2909
Location: 0x77760000
typedef 06 Oct 2014, 14:05
>> along with << are generally used for stream IO operations in C++ but they can also inherently be used for arithmetic operations.
Post 06 Oct 2014, 14:05
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1694
Location: Toronto, Canada
AsmGuru62 06 Oct 2014, 14:39
I always found these (<< and >>) confusing.
I like how C# has a better solution.
C# has ToString() method at the very base of every class.
So, instead of ">>" the simple call "ToString()" can be used on any object.
Code is slightly longer on disk, but easier to read.
Post 06 Oct 2014, 14:39
View user's profile Send private message Send e-mail Reply with quote
ManOfSteel



Joined: 02 Feb 2005
Posts: 1154
ManOfSteel 06 Oct 2014, 17:30
It's straightforward: << (AKA the insertion operator) and >> (AKA the extraction operator) show the direction taken by data, i.e. going to a stream or coming from a stream.

Code:
std::cout << "Hello World!";    

writes the Hello World! string to the standard output (usually the screen).

Code:
std::cin >> inVar;    

reads the contents of the standard input (usually the keyboard) into the inVar variable.

It all depends on the context. These operators become bitshift operators if the part on the left is an int or char variable.
Post 06 Oct 2014, 17:30
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.