1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#include <memory>
#include <iostream>
struct Foo
{
std::shared_ptr<Foo> next;
~Foo()
{
std::cout << "~Foo" << std::endl;
}
};
int
main()
{
std::shared_ptr<Foo> A = std::shared_ptr<Foo>(new Foo);
A->next = std::shared_ptr<Foo>(new Foo);
A->next->next = A;
}
|