comp.lang.ada
 help / color / mirror / Atom feed
From: "Barry L. Dorough" <bdorough@phaseiv.com>
Subject: Function Pointers
Date: 1998/04/13
Date: 1998-04-13T00:00:00+00:00	[thread overview]
Message-ID: <353257CC.211B84EE@phaseiv.com> (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 );
}





             reply	other threads:[~1998-04-13  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-13  0:00 Barry L. Dorough [this message]
1998-04-13  0:00 ` Function Pointers 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
replies disabled

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