#include using namespace std; void change(int* x) // essential we made a new pointer and pointed it to the same address as p { *x = 20; // this dereferences our pointer so we can change the variable. remember this is pointing to the memory on the heap } int main() { int* p = new int; // allocated new memory on the heap and gave it a pointer *p = 10; // the derefereenced pointer is assigned to value 10 cout << p << " " << *p << "\n"; // this should print out the memory address and the value 10 change(p); cout << p << " " << *p << "\n"; delete p; // this will delete the memory address stored here system("pause"); // this is so we can read the console window return 0; }