On Tue, 25 May 2004 12:22:52 -0400, "noe" <> wrote:
>Hello, I'm writing a file system filter driver and I've found in an example
>this sentence:
>
>if (VALID_FAST_IO_DISPATCH_HANDLER( fastIoDispatch, FastIoRead )) {
>
> return (fastIoDispatch->FastIoRead)(
> FileObject,
> FileOffset,
> Length,
> Wait,
> LockKey,
> Buffer,
> IoStatus,
> nextDeviceObject );
> }
>
>
>--------------------------------
>I've never seen this type of 'return'. What is it doing here? Why does it
>have so much parameters? Can it be a routine?
It is a call through either a pointer-to-function or a function object,
depending on how FastIoRead is defined.
Here's a trivial example using a pointer-to-function:
#include <iostream>
using std::cout;
using std::endl;
double crunch();
double sum(double a, double b)
{
return a + b;
}
int main()
{
cout << crunch() << endl;
return 0;
}
double crunch()
{
typedef double (*func_t)(double, double);
func_t fp = sum;
return (fp)(2.2, 3.3);
// return fp(2.2, 3.3);
// return (*fp)(2.2, 3.3);
}
Note that any of the three return statements shown do exactly the same
thing. The language provides some leeway on how to write a call through a
pointer-to-function.
-leor
>
>Thanks in advance.
>
--
Leor Zolman --- BD Software ---
www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html