If the function that accepts int& is passed to *p , where p is a pointer to an int , then the function will work with the original data located at this address or with its copy?

  • and how will the “data at address p” (that is, the data that are at the address that is written in p) differ from the original? - KoVadim

1 answer 1

With the original at p . You could easily jot down a couple of lines and see this:

 void f(int&i) { ++i; } int main(int argc, const char * argv[]) { int x = 5; int * p = &x; f(*p); cout << x << endl; }