I'm new to C++ and currently learning about pointers. This was from my notes:
#include <iostream>
using namespace std;
int main()
{
int value1 =5, value2 = 15;
int *p1, *p2;
p1 = &value1; //why does it mean by the & here?
p2 = &value2; //and here?
*p1 = 10;
*p2 = *p1;
p1 = p2;
*p1 = 20;
cout << "Value1 = " << value1 << "Value 2 = " << value2;
return 0;
}
What does the &
mean here?