Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcvax!ukc!pyrltd!slxsys!jclark!jjc From: jjc@jclark.UUCP (James Clark) Newsgroups: comp.lang.c++ Subject: overloaded functions Summary: rules could be smarter? Message-ID: Date: 30 May 89 10:07:23 GMT Sender: jjc@jclark.UUCP Distribution: comp Organization: None Lines: 31 I was wondering whether the C++ rules for overloaded function names could not be a little smarter. For example, the following won't compile (with cfront 1.2 or g++): struct SubString { }; struct String { String(SubString &); operator char *(); }; String operator+(String &, String &); String operator+(String &, const char *); String foo(SubString &s, String &t) { return s + t; } The choice here is between: - converting s to a String and doing nothing to t; and - converting s to a String and converting t to a char *. It would be nice if C++ was able to do the right thing, and choose the first. Is there some good reason why it doesn't? James Clark jjc@jclark.uucp