home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / pascal / 4887 < prev    next >
Encoding:
Internet Message Format  |  1992-08-17  |  1.3 KB

  1. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!rpi!usc!sdd.hp.com!network.ucsd.edu!cogsci!miller
  2. From: miller@cogsci.ucsd.EDU (Jeff Miller)
  3. Newsgroups: comp.lang.pascal
  4. Subject: Turbo Pascal 6.0 OOP Question
  5. Message-ID: <1535@cogsci.ucsd.EDU>
  6. Date: 17 Aug 92 17:49:17 GMT
  7. Organization: University of California, San Diego
  8. Lines: 36
  9.  
  10. Is it possible to pass an object's method as a procedure parameter?
  11. The compiler tells me I am making an illegal function reference
  12. each time I try to do this.
  13.  
  14. Here is a crude code-like sketch of what I am trying to do,
  15. although I know there are other errors here:
  16.  
  17. Type Generic(Object)
  18.    Function X : Real; Virtual;
  19.    Function Y : Real; Virtual;
  20.    End;
  21.  
  22. Type RealFunc = Function : Real;
  23.  
  24. Function Integrate(LowX, HighX : Real; Func : RealFunc);
  25. Begin
  26. { Function integration stuff from Numerical Recipes.
  27.   The relevant point is that it calls Func, the function to be integrated. }
  28. End;
  29.  
  30. Begin
  31. Writeln(Integrate(0,1,Object1.X));
  32. Writeln(Integrate(0,1,Object1.Y));
  33. End.
  34.  
  35. At the point of the writeln's,
  36. The compiler tells me I have an illegal function reference.
  37.  
  38. If I put in "Far" up by the "Virtual"s, it stops there saying
  39. that is not an OK thing to do.
  40.  
  41. Anyone know how to accomplish my goal here?
  42. Thanks for any info.
  43.  
  44. Jeff Miller
  45. jomiller@ucsd.edu
  46.