Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!agate!e260-2a!c60c-2ca From: c60c-2ca@e260-2a.berkeley.edu (Andrew Choi) Newsgroups: comp.lang.c++ Subject: Re: Resolving an Overloaded Function Call Keywords: overloading Message-ID: <1990May3.030546.1885@agate.berkeley.edu> Date: 3 May 90 03:05:46 GMT References: <35925@think.Think.COM> Sender: usenet@agate.berkeley.edu (USENET Administrator;;;;ZU44) Reply-To: c60c-2ca@e260-2a (Andrew Choi) Organization: University of California, Berkeley Lines: 29 In article <35925@think.Think.COM> simons@think.com (Joshua Simons) writes: > > I have a question about resolving overloaded function calls in >C++. In Lippman's book, 'The C++ Primer' there is an example on page 155 >which says that the following function call: > > print( 'a' ) ; > >exactly matches the overloading: > > extern void print( char ) ; > > Is this an error? I don't know C++, but in C the type of the >expression 'a' is 'int' not char so I don't see how this could be an >exact match. Is C++ different from C in this regard? No, this is not an error. In C++ version 2.0, a character literal/variable is considered to match perfectly with a formal parameter of type `char'. It will only considered to match an `int' (and higher derived type) if a perfect match is not found. Hope this helps. Andrew Choi Internet Address: c60c-2ca@web.berkeley.edu Standard Disclaimer