Path: utzoo!attcan!uunet!mcvax!hp4nl!tnosoes!tom From: tom@tnosoes.UUCP (Tom Vijlbrief) Newsgroups: comp.lang.c++ Subject: Re: CFRONT braindamaged? (Or me?) Message-ID: <439@tnosoes.UUCP> Date: 10 Feb 89 16:03:28 GMT References: <2205@galaxy> Organization: TNO Institute for Perception, Soesterberg, The Netherlands Lines: 67 dave@andromeda.rutgers.edu (Dave Bloom) writes: >Hi there. We're running AT&T's C++ Ver 1.2.1, and as far as I'm >concerned, the following should work hunky-dorey. Does anybody >see anything wrong with my syntax? Yes, gnu g++ 1.32 reports: t.c:8: assignment between incompatible pointer types t.c:9: assignment between incompatible pointer types t.c:10: assignment between incompatible pointer types This can be corrected: ====================== class zz { public: void (zz::* xx)(char *); void a(char* s) { printf("function a: %s\n", s); } void b(char* s) { printf("function b: %s\n", s); } void c(char* s) { printf("function c: %s\n", s); } zz(int i) { if(i==0) xx= &(zz::a); else if(i==1) xx= &(zz::b); else xx= &(zz::c); } }; main() { zz dave(1); dave.xx("Yes!!!"); } ========== This produces: t.c:17: invalid call via pointer-to-member function Changing the code to: class zz { public: void (zz::* xx)(char *); void a(char* s) { printf("function a: %s\n", s); } void b(char* s) { printf("function b: %s\n", s); } void c(char* s) { printf("function c: %s\n", s); } void e() { xx(this, "yes"); } zz(int i) { if(i==0) xx= &(zz::a); else if(i==1) xx= &(zz::b); else xx= &(zz::c); } }; main() { zz dave(1); dave.e(); } ====== produces the correct result. Tom =============================================================================== Tom Vijlbrief TNO Institute for Perception P.O. Box 23 Phone: +31 34 63 62 77 3769 ZG Soesterberg E-mail: tnosoes!tom@mcvax.cwi.nl The Netherlands or: uunet!mcvax!tnosoes!tom ===============================================================================