TITLE: namespaces and overloading (Newsgroups: comp.lang.c++.moderated, 25 June 99) LAVRIJSEN: Wim Lavrijsen >>what are the rules for overloading across namespaces? NARAN: sbnaran@localhost.localdomain (Siemel Naran) >I don't think there are any rules. The bottom line is that when you >make a function call, there must be only one function to call. CLAMAGE: Steve Clamage More specifically, overloading does not occur across scopes. If functions are declared in different scopes, something must be done to make them visible in the same scope -- such as using-directives or using-declarations -- before they can participate in overloading. When you call a function, the visible functions of that name are compared for the best match. Functions that are not visible don't get considered. Examples: namespace A { int f(int); } namespace B { int f(double); } int i = f(1); // error, no f is visible using A::f; int j = f(2.0); // calls f(int), because f(double) is not visible using B::f; int k = f(3.0); // both are visible, f(double) is best match