#include <iostream>
struct Abstract
{
virtual void print() = 0;
virtual ~Abstract() = default;
};
struct Concrete : Abstract
{
virtual void print() override
{
std::cout << "Concrete\n";
}
};
Abstract& foo()
{
static Concrete c;
return c;
}
int main()
{
foo().print();
}
coliru.stacked-crooked.com/a/cedf0ea1d25f9a12