#include <iostream>
#include <memory>
using namespace std;
int main()
{
shared_ptr<int> p(new int(42));
int *q = p.get();
{
shared_ptr<int>(q); //这一句
}
int foo = *p;
cout << foo << endl;
return 0;
}
#include <iostream>
#include <memory>
using namespace std;
int main()
{
shared_ptr<int> p(new int(42));
int *q = p.get();
{
shared_ptr<int>(q); //这一句
}
int foo = *p;
cout << foo << endl;
return 0;
}