Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!wuarchive!uunet!news.uu.net!taumet!steve From: steve@taumet.com (Stephen Clamage) Newsgroups: comp.lang.c++ Subject: Re: Overloading of functions with semi-identical signatures Message-ID: <742@taumet.com> Date: 22 May 91 15:59:56 GMT References: <14679@ector.cs.purdue.edu> Organization: Taumetric Corporation, San Diego Lines: 29 svb@cs.purdue.EDU (Stephan Bechtolsheim) writes: >Look at the following source code please: >// Have three functions with almost identical signatures. >int F (int); >int F (int &); >int F (const int &); The first two declarations cannot be distinguished, and the compiler should complain about them. Evidently, your compiler does not complain, and picks one arbitrarily. If overloaded function signatures differ only in that of two corresponding parameters, one is type T and the other is T&, the declarations are inherently ambiguous and should be detected a compilation time. On the other hand, these two int F(int&); int F(const int&); are not ambiguous: int i; const int ci; F(i); // calls f(int&), since it is an exact match F(ci); // calls f(const int&), since it is an exact match -- Steve Clamage, TauMetric Corp, steve@taumet.com