home *** CD-ROM | disk | FTP | other *** search
- 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
- From: wong@fraser.sfu.ca (Sam S. Wong)
- Newsgroups: comp.lang.c
- Subject: Need help: array of pointers to member functions C++.
- Message-ID: <wong.724526569@sfu.ca>
- Date: 16 Dec 92 17:22:49 GMT
- Article-I.D.: sfu.wong.724526569
- Sender: news@sfu.ca
- Organization: Simon Fraser University, Burnaby, B.C., Canada
- Lines: 42
-
- HELP: I can't assign the address of my integer member functions to a pointer
- in my array of pointers to integer functions. What's wrong?
-
- -------------------------------------
-
-
-
- class dummy {
- public:
- int hello(void);
- };
-
- int just_hello (void);
-
- dummy dumb;
- int (*fnptr[10])();
-
-
- main()
- {
- dumb.hello();
- fnptr[1] = just_hello;
- (*fnptr[1])();
- fnptr[1] = dummy::hello; // <- compile error
- fnptr[1] = dumb.hello; // <- compile error
- (*fnptr[1])();
- }
-
-
- int dummy::hello (void)
- {
- printf ("\nhello");
- }
-
-
- int just_hello (void)
- {
- printf ("\njust_hello");
- }
-
-
- -----------------------------------------------------
-