Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!ames!ncar!boulder!sunybcs!rutgers!att!whuts!homxb!dean From: dean@homxb.ATT.COM (D.JONES) Newsgroups: comp.lang.c++ Subject: Re: CFRONT braindamaged? (Or me?) Summary: this, what's this this ??? Message-ID: <2944@homxb.ATT.COM> Date: 8 Feb 89 00:08:00 GMT References: <2205@galaxy> Organization: AT&T BL Holmdel NJ USA Lines: 48 In article <2205@galaxy>, 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? > > class zz { > public: > void (*xx)(char*); > void b(char* s) { printf("function b: %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!!!"); > } > rutgers\ | Dave Bloom > galaxy >!andromeda!dave -or- dave@andromeda.rutgers.edu | Work: (201)648-5085 > pyramid/ | Dave, The problem seems to be that the compiler does not recognize xx as a `member function', where a,b, & c are member functions. Since they are member functions they expect a pointer to the object or a ``this'' pointer as the first argument. If you call them indirectly through xx the ``this'' pointer is not added to the stack of xx, it pulls off "Yes!!!" as ``this'' and as for where the second argument, or s points, all bets are off ..... Dean S Jones UNICAD/IDS AT&T Bell Labs Holmdel, NJ dean@homxb.ATT.COM Line.Eater() Line.Eater() Line.Eater() Line.Eater() Line.Eater() Line.Eater() Line.Eater() Line.Eater() Line.Eater()