comp.lang.ada
 help / color / mirror / Atom feed
* Function Pointers
@ 1998-04-13  0:00 Barry L. Dorough
  1998-04-13  0:00 ` Matthew Heaney
  1998-04-14  0:00 ` Jerry van Dijk
  0 siblings, 2 replies; 5+ messages in thread
From: Barry L. Dorough @ 1998-04-13  0:00 UTC (permalink / raw)



Is there any way to implement function pointers in Ada?  Below is a
sample C program using function pointers.  How can I do this in Ada?

                                                                Thanks
in advance,
                                                                Barry
Dorough


#include <iostream.h>
double Add( double x, double y );
double Subtract( double x, double y );
double Combine( double p, double q, double (*fcn)(double r, double s) );

int main()
{
    double w = 20.0;
    double x = 5.0;
    double y = Combine( w, x, Add );
    double z = Combine( w, x, Subtract );
    cout << w << "  " << x << "  " << y << "  " << z << endl;
    return 0;
}
double Add( double x, double y )
{
    return x+y;
}
double Subtract( double x, double y )
{
    return x-y;
}
double Combine( double p, double q, double (*fcn)(double r, double s) )
{
    double a = 10.0 + p;
    return fcn( a, q );
}





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1998-04-16  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-13  0:00 Function Pointers Barry L. Dorough
1998-04-13  0:00 ` Matthew Heaney
1998-04-14  0:00 ` Jerry van Dijk
1998-04-15  0:00   ` Robert Dewar
1998-04-16  0:00     ` Jerry van Dijk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox