Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!microsoft!jimad From: jimad@microsoft.UUCP (Jim ADCOCK) Newsgroups: comp.lang.c++ Subject: Re: Resolving an Overloaded Function Call Keywords: overloading Message-ID: <54490@microsoft.UUCP> Date: 7 May 90 18:57:37 GMT References: <35925@think.Think.COM> <1990May3.030546.1885@agate.berkeley.edu> Reply-To: jimad@microsoft.UUCP (Jim ADCOCK) Organization: Microsoft Corp., Redmond WA Lines: 29 In article <1990May3.030546.1885@agate.berkeley.edu> c60c-2ca@e260-2a (Andrew Choi) writes: >In article <35925@think.Think.COM> simons@think.com (Joshua Simons) writes: .... >> print( 'a' ) ; >> >>exactly matches the overloading: >> >> extern void print( char ) ; .... > 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. > Right. To make this even clearer, a char const 'a' is of type int in C, but is of type char in C++. For example: sizeof('c') == sizeof(int) in C, whereas sizeof('c') == sizeof(char) and sizeof(char) == 1 /* by definition */ in C++. These definitions may not be recognized correctly by compilers predating 2.0 compatibility.