If not ambiguous, what should it do?
-------------------------
#include <stdio.h>
struct B {};
struct A {
operator const int &() const { printf("Called operator int!\n");
return 1; }
operator B() { B b; return b; }
};
int operator && (B b, int i)
{
printf("Called operator &&!\n");
return(0);
}
int main()
{
A a;
return a && 1;
}
-------------
Mark Williams
Sent via Deja.com http://www.deja.com/
Before you buy.
[ Send an empty e-mail to c++-...@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
It will compile but produces warnings. I have modified your
example so that warnings don't exist. There's nothing
exactly "broken" syntatically but it seems useless in the
context provided though.
#include <stdio.h>
struct B {};
const int ONE = 1;
struct A {
operator const int &() const
{
printf("Called operator int!\n");
return ONE;
}
operator B() { B b; return b; }
};
int operator && (B, int)
{
printf("Called operator &&!\n");
return(0);
}
int main() {
A a;
int temp = a;
return a && temp;
}
- William Bloodworth
> Should the following compile (or is it ambiguous).
>
> If not ambiguous, what should it do?
> #include <stdio.h>
>
> struct B {};
> struct A {
> operator const int &() const { printf("Called operator int!\n");
> return 1; }
> operator B() { B b; return b; }
> };
>
> int operator && (B b, int i)
> {
> printf("Called operator &&!\n");
> return(0);
> }
>
> int main()
> {
> A a;
>
> return a && 1;
> }
[ Send an empty e-mail to c++-...@netlab.cs.rpi.edu for info ]