Re: left handed use of conditional
- From: "Nicholas M. Makin" <nmaximillian@xxxxxxxxx>
- Date: Fri, 27 Apr 2007 18:24:22 -0400
"David Anton" <DavidAnton@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F50BB529-0D27-41E0-84B6-0639484B7B4B@xxxxxxxxxxxxxxxx
Regarding the 'other surprising cases'; are you sure there's no weird
compiler setting you have to have to get these to work?
I tried the following (your first case) and it won't compile:
class foo {
void test() {
int a, b;
(a < b ? f : g)(10);
}
void f(int i) {}
void g(int i) {}
};
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
Your class example also did not compile for me. However when I deleted the
class construct and moved the definitions for f() & g() to before test it
did compile:
int f(int i) { return i - 1;}
int g(int i) { return i + 1;}
int test(int i) {
int a=1, b=0;
return ((a < b) ? f : g)(i);
}
(I changed the return types to make sure it worked) and worked
wonderfully...
I am confused on why this didn't work from within the class. I did try a few
permutations of things to see if I could get it to work.
class foo {
int f(int i) { return i - 1;}
int g(int i) { return i + 1;}
int test(int i) {
int a=1, b=0;
return ((a < b) ? f : g)(i);
}
};
returns the error: "term does not evaluate to a function" in VC++ (VS6)
and even making it: ((a < b) ? foo::f : foo::g)(i);
did not resolve the problem.
and foo::((a < b) ? f : g)(i); is an nonsencical as it looks.
Even tried to define all of the functions outside of the class declaration
and it generates the same error.
Just when I think I am getting to the point where I understand things!!!
.
- Follow-Ups:
- Re: left handed use of conditional
- From: Nicholas M. Makin
- Re: left handed use of conditional
- References:
- left handed use of conditional
- From: Nicholas M. Makin
- Re: left handed use of conditional
- From: Carl Daniel [VC++ MVP]
- Re: left handed use of conditional
- From: David Anton
- left handed use of conditional
- Prev by Date: Re: left handed use of conditional
- Next by Date: Re: left handed use of conditional
- Previous by thread: Re: left handed use of conditional
- Next by thread: Re: left handed use of conditional
- Index(es):
Relevant Pages
|