C++ question

Discussion in 'Code Snippets and Tutorials' started by bladeoftalwar, Oct 9, 2007.

Thread Status:
Not open for further replies.
  1. bladeoftalwar

    bladeoftalwar Level IV

    Joined:
    May 20, 2007
    Messages:
    1,052
    Likes Received:
    1
    i'm in C++ right now and we're learning some coding. i have basic programming knowledge but when i look at the program, i see >> and << used interchangably.

    what do they mean? and when/why do i use them?
     
  2. vinceraf

    vinceraf Level III

    Joined:
    Jan 29, 2007
    Messages:
    722
    Likes Received:
    0
    Location:
    Europe - Italy
    Dunno if what I'm going to say can be useful to you but... I'm studying C++ since very few days, maybe two week, and I've understood that >> and << are the symbols for shifting the bits.
    For example b>>2 is used to shift the element b to right for 2 positions
    and << is used to shift to left.
    Then
    Code (Text):
    1. <div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">cout<<'......'<<</li></ol></div>
    is used to write a message in the screen, and
    Code (Text):
    1. <div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">cout<<variable<<</li></ol></div>
    to write the value of the variable.
    Instead you have to use >> when the system has to read a variable, using
    Code (Text):
    1. <div class="text" id="{CB}" style="font-family: monospace;"><ol><li style="padding: 0 5px; background-color: #fff; line-height: 16px; border-bottom: 1px solid #efefef; border-left: 1px solid #999;">cin >>variable</li></ol></div>
    For now these are the only things I know about >> and << ^^"
     
Thread Status:
Not open for further replies.