home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.next.programmer
- Path: 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
-
- 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
-