. std::shared_ptr . , , ,
std::shared_ptr<std::string> ptr;
shared_ptr ptr, .
{
std::shared_ptr<foo> foo_ptr = std::make_shared<foo>();
ptr = foo_ptr->bar;
}
shared_ptr foo_ptr, foo foo, bar. bar ptr. , bar ( ), bar ptr . foo_ptr , , foo, bar. bar , . , . shared_ptr ( ), , , . ( - ptr = foo_ptr->bar), , ptr, .
std::cout << *ptr << std::endl;
ptr , , . , ptr , , , , . , std::shared_ptr , . . , , , .