#include <iostream>
using namespace std;
void passPointer( int * x) ;
int main( )
{
int value = 10 ;
int * vPtr = & value;
std:: cout << "value before function call: " << value << '\n ' ;
std:: cout << "Address contained by vPtr before function call: " << vPtr << '\n ' ;
passPointer( vPtr) ;
std:: cout << "value after function call: " << value << '\n ' ;
std:: cout << "Address contained by vPtr after function call: " << vPtr << '\n ' ;
}
void passPointer( int * x) {
int local_variable;
std:: cout << "Address of local_variable: " << & local_variable << '\n ' ;
* x = 20 ; // derefence allows one to get a reference to the object pointed to.
x = & local_variable; // not dereferencing means we're modifying a copy of the pointer.
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdm9pZCBwYXNzUG9pbnRlcihpbnQgKngpOwoKaW50IG1haW4oKQp7CiAgICBpbnQgdmFsdWUgPSAxMDsKICAgIGludCogdlB0ciA9ICZ2YWx1ZTsKCiAgICBzdGQ6OmNvdXQgPDwgInZhbHVlIGJlZm9yZSBmdW5jdGlvbiBjYWxsOiAiIDw8IHZhbHVlIDw8ICdcbic7CiAgICBzdGQ6OmNvdXQgPDwgIkFkZHJlc3MgY29udGFpbmVkIGJ5IHZQdHIgYmVmb3JlIGZ1bmN0aW9uIGNhbGw6ICIgPDwgdlB0ciA8PCAnXG4nOwoKICAgIHBhc3NQb2ludGVyKHZQdHIpOwoKICAgIHN0ZDo6Y291dCA8PCAidmFsdWUgYWZ0ZXIgZnVuY3Rpb24gY2FsbDogIiA8PCB2YWx1ZSA8PCAnXG4nOwogICAgc3RkOjpjb3V0IDw8ICJBZGRyZXNzIGNvbnRhaW5lZCBieSB2UHRyIGFmdGVyIGZ1bmN0aW9uIGNhbGw6ICIgPDwgdlB0ciA8PCAnXG4nOwp9Cgp2b2lkIHBhc3NQb2ludGVyKGludCAqeCl7CiAgICBpbnQgbG9jYWxfdmFyaWFibGU7CgogICAgc3RkOjpjb3V0IDw8ICJBZGRyZXNzIG9mIGxvY2FsX3ZhcmlhYmxlOiAiIDw8IC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