Article View: comp.sys.next.programmer
Article #2176Pointers to functions in method definitions
From: A.B. McLean
Date: Mon, 04 Jan 1993 17:20
Date: Mon, 04 Jan 1993 17:20
35 lines
1205 bytes
1205 bytes
POINTERS TO FUNCTIONS IN METHOD DEFINITIONS
I want to write a method that will accept a pointer to a C function.
For example, let the function be a simple Gaussian:-
void gaussian(x,a,y)
float x,a[],*y;
{
float arg;
arg = (x-a[2])/a[3];
*y += a[1]*exp(-arg*arg);
}
In the interface file I would expect (Kernigham amd Ritchie section 5.11)
the method definition to look like
- methodName:void(*gaussian)(float, float*, float*);
and in the implementation file I may have
- methodName:void(*gaussian)(float, float*, float*)
{
// ...
return self;
}
When I try to do this the compiler gives me the message
parse error before `void'
Any suggestions ?
Alastair McLean
alastair@hecate.phy.queensu.ca
Technical Details
Message-ID:
<C0CAtI.KqM@knot.ccs.queensu.ca>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!wupost!cs.utexas.edu!torn!news.ccs.queensu.ca!newsShow Full Headers
Complete Article Headers
Newsgroups: comp.sys.next.programmer Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!wupost!cs.utexas.edu!torn!news.ccs.queensu.ca!news From: alastair@hecate.phy.queensu.ca (A.B. McLean) Subject: Pointers to functions in method definitions Message-ID: <C0CAtI.KqM@knot.ccs.queensu.ca> Keywords: method Sender: news@knot.ccs.queensu.ca (Netnews control) Organization: Queen's University, Kingston Date: Mon, 4 Jan 1993 17:20:06 GMT Lines: 35