If you do want to keep this method:
void Foo::Bar(Baz& x)
{
z = &x;
}
But still want to be able to set z
as nullptr
, you can add an overload for Bar
that specifically takes a nullptr
argument:
void Foo::Bar(std::nullptr_t nullp)
{
z = nullp;
}