Hi all,
I'm trying to create a simple function in MS Visual Studio which would take a function and a range of values, divide that range into 500 equal steps, and barf out the results to a CLR richTextBox.
The function looks like this:
void Form1::Range(double from, double to, double f(double))
{
for (int i = 0; i < 501; i++)
{
double x = (double)from + (to - from) * ((double)i / 500);
double result = f(x);
richTextBox7->AppendText(x.ToString() + "\t" + result.ToString());
double ratio = (double)i/500.0;
}
}
And when I call it I say this:
Range (0, 5, specweight);
Here's the function I'm passing as an argument (for now).
double Form1::specweight(double fkhz) {
double expr;
expr = fkhz/0.7-0.7/fkhz;
return(1.0/sqrt(1.0+0.07*expr*expr));
}
Soooo, when I call it as above, Visual Studio says "function call missing argument list; use '&Pitch2Gui_Port3::Form1::specweight' to create a pointer to member"
If I call it like
Range (0, 5, specweight());
it complains that specweight "does not have 0 arguments"
If I call it like
Range (0, 5, specweight(double))
it says 'double' should be preceded by ')'
I could have sworn this worked in a C context (with the first method of calling it.) Maybe the difference is that these are member functions of Form1?
I've tried changing the argument to a pointer to function but can't get that to work either. Any tips?