#include <iostream>
#include <memory>

using namespace std;

class second;

class first {
	unique_ptr<second> p2;
	first() {}
public:
	static shared_ptr<first> create() {
		shared_ptr<first> f{new first};
		f->p2 = make_unique<second>(f);
		return f;
	}
};

class second {
	shared_ptr<first> p1;
public:
	second(shared_ptr<first> arg) : p1(arg) {}
};

int main()
{
	auto f = first::create();
}