fork(1) download
#include <iostream>
#include <string>
#include <memory>

struct Other
{
	virtual void print() = 0;
	virtual ~Other() = default;
};

struct Base
{
	Base(Other *o)
	{
		o->print();
	}
	virtual ~Base() = default;
};
struct Derived : Base
{
	Derived();
	virtual ~Derived();
private:
	struct My;
	std::unique_ptr<My> my;
};

int main()
{
	Derived d;
}

struct Derived::My : Other
{
	std::string s = "It works";
	virtual void print()
	{
		std::cout << s << std::endl;
	}
};
Derived::Derived()
: my(new My)
, Base(my.get())
{
}
Derived::~Derived() = default;
Runtime error #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout

Standard output is empty