#include <iostream>
void modify_pointer_byvalue(const char* p)
{
p = "by value";
}
void modify_pointer_byreference(const char*& p)
{
p = "by reference";
}
void modify_pointer_byindirection(const char** p)
{
*p = "by indirection";
}
int main()
{
const char* ptr = "original";
std::cout << "Before modification: \"" << ptr << "\"\n";
modify_pointer_byvalue(ptr);
std::cout << "After value: \"" << ptr << "\"\n";
modify_pointer_byreference(ptr);
std::cout << "After reference: \"" << ptr << "\"\n";
modify_pointer_byindirection(&ptr);
std::cout << "After indirection: \"" << ptr << "\"\n";
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdm9pZCBtb2RpZnlfcG9pbnRlcl9ieXZhbHVlKGNvbnN0IGNoYXIqIHApCnsKICAgIHAgPSAiYnkgdmFsdWUiOwp9Cgp2b2lkIG1vZGlmeV9wb2ludGVyX2J5cmVmZXJlbmNlKGNvbnN0IGNoYXIqJiBwKQp7CiAgICBwID0gImJ5IHJlZmVyZW5jZSI7Cn0KCnZvaWQgbW9kaWZ5X3BvaW50ZXJfYnlpbmRpcmVjdGlvbihjb25zdCBjaGFyKiogcCkKewogICAgKnAgPSAiYnkgaW5kaXJlY3Rpb24iOwp9CgppbnQgbWFpbigpCnsKICAgIGNvbnN0IGNoYXIqIHB0ciA9ICJvcmlnaW5hbCI7CiAgICBzdGQ6OmNvdXQgPDwgIkJlZm9yZSBtb2RpZmljYXRpb246IFwiIiA8PCBwdHIgPDwgIlwiXG4iOwoKICAgIG1vZGlmeV9wb2ludGVyX2J5dmFsdWUocHRyKTsKICAgIHN0ZDo6Y291dCA8PCAiQWZ0ZXIgdmFsdWU6IFwiIiA8PCBwdHIgPDwgIlwiXG4iOwoKICAgIG1vZGlmeV9wb2ludGVyX2J5cmVmZXJlbmNlKHB0cik7CiAgICBzdGQ6OmNvdXQgPDwgIkFmdGVyIHJlZmVyZW5jZTogXCIiIDw8IHB0ciA8PCAiXCJcbiI7CgogICAgbW9kaWZ5X3BvaW50ZXJfYnlpbmRpcmVjdGlvbigmcHRyKTsKICAgIHN0ZDo6Y291dCA8PCAiQWZ0ZXIgaW5kaXJlY3Rpb246IFwiIiA8PCBwdHIgPDwgIlwiXG4iOwp9