#include <iostream>
#include <string>
using namespace std;


void reassign(string* & a);
int main()
{
    string *x = new string("abcd");
    cout <<"x is " << *x <<" at " << x <<endl;    //"x is abcd at 0x95b7008"
    reassign(x);
    cout <<"x is " << *x <<" at " << x <<endl;    //"x is efgh at 0x95b7030"
    delete x;
    return 0;
}

void reassign(string* & a)
{
	string *old = a;
    a = new string("efgh");
    delete old;
}
