& Operator in C++

Asked

Viewed 24 times

0

I am studying C++ and I have doubts about this operator &, when should I use?

void funct(int *var) {

    (*var)++;
}

void funct(int& var) {

    var++;
}

These two function increments the varial, but I can’t tell the difference.

  • 1

    I think this answers http://answall.com/q/56470/101

  • In the example does not work in C, why?

  • Because C doesn’t have pointer references.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.