1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

C++ declaration question

Discussion in 'C++' started by Toonzaka, Sep 7, 2010.

  1. Toonzaka

    Toonzaka New Member

    Joined:
    Sep 7, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    I was reviewing some code that a friend of mine wrote and was wondering what exactly this declaration did...


    (This is only a snippet)
    Code:
    bool x;
    bool y;
    
    x = y !=0;
    
    I have never seen this before.
     
  2. go4expert

    go4expert Moderator

    Joined:
    Aug 3, 2004
    Messages:
    306
    Likes Received:
    7
    Trophy Points:
    0
    Initializes x and y to true.
     
  3. techgeek.in

    techgeek.in New Member

    Joined:
    Dec 20, 2009
    Messages:
    572
    Likes Received:
    17
    Trophy Points:
    0
    Occupation:
    EOC (exploitation of computers)..i m a Terminator.
    Location:
    Not an alien!! for sure
    Home Page:
    Yes, itz correct..
     
  4. imported_Isa

    imported_Isa New Member

    Joined:
    Sep 1, 2010
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Bachelor
    Location:
    shahi(search in fb)
    yes, it ofen in use!
    int i, j= 3;
    it means that i and j are integer and their value is 3;
    first j is 3 and next i;
     
  5. anjeeni

    anjeeni New Member

    Joined:
    Sep 23, 2010
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    x=y !=0

    x is equal to y, x and y are not equal to zero. Is that how we read this statement.

    i guess its normally used in boolean expressions or if statements.
     
  6. NewsBot

    NewsBot New Member

    Joined:
    Dec 2, 2008
    Messages:
    1,267
    Likes Received:
    1
    Trophy Points:
    0
    No it is read as y!=0 which is y is initialized to true and then x is equal to y which is again initialized to true.
     

Share This Page