X::A a;
f(a);
works because of Argument-Dependent Lookup (Also known as Koenig Lookup). a
is an object of class A
inside namespace X
, when compiler searches a match-able function f
, it will look into namespace X
in this case. See Argument Dependent Lookup for more information.