home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18473 < prev    next >
Encoding:
Text File  |  1992-12-16  |  1.1 KB  |  54 lines

  1. Path: sparky!uunet!usc!cs.utexas.edu!uwm.edu!ogicse!news.u.washington.edu!uw-beaver!cs.ubc.ca!newsserver.sfu.ca!sfu.ca!wong
  2. From: wong@fraser.sfu.ca (Sam S. Wong)
  3. Newsgroups: comp.lang.c
  4. Subject: Need help: array of pointers to member functions C++.
  5. Message-ID: <wong.724526569@sfu.ca>
  6. Date: 16 Dec 92 17:22:49 GMT
  7. Article-I.D.: sfu.wong.724526569
  8. Sender: news@sfu.ca
  9. Organization: Simon Fraser University, Burnaby, B.C., Canada
  10. Lines: 42
  11.  
  12. HELP: I can't assign the address of my integer member functions to a pointer 
  13. in my array of pointers to integer functions. What's wrong?
  14.  
  15. -------------------------------------
  16.  
  17.  
  18.  
  19. class dummy {
  20.  public:
  21.  int hello(void);
  22. };
  23.  
  24. int just_hello (void);
  25.  
  26. dummy dumb;              
  27. int (*fnptr[10])();
  28.  
  29.  
  30. main()
  31.   dumb.hello();
  32.   fnptr[1] = just_hello;
  33.   (*fnptr[1])();
  34.   fnptr[1] = dummy::hello;  // <- compile error   
  35.   fnptr[1] = dumb.hello;    // <- compile error
  36.   (*fnptr[1])();
  37. }
  38.  
  39.  
  40. int dummy::hello (void)
  41. {
  42.   printf ("\nhello");
  43. }
  44.  
  45.  
  46. int just_hello (void)
  47. {
  48.   printf ("\njust_hello");
  49. }
  50.  
  51.  
  52. -----------------------------------------------------
  53.