I am starting C++ and I have seen "&" this wery often. What does it do?
I am starting C++ and I have seen "&" this wery often. What does it do?
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
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