Thread: & - What does it ...

  1. #1
    Unregistered
    Guest

    Unhappy & - What does it ...

    I am starting C++ and I have seen "&" this wery often. What does it do?

  2. #2
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Depends on the context it's used in. Here's some examples:
    Code:
    int i;
    &i  //in this case it's accessing the pointer to your int i
    
    if(1&0) //in this case it's a bitwise AND
    
    if((1==1)&&(2==2)) //in this case it's a logical AND

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    16
    You can use & to make a reference to variable too:

    int i = 3; // an int variable i
    int& ref = i; // a reference to i
    ref = 4; //now i has a value of 4

Popular pages Recent additions subscribe to a feed