Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!deimos.cis.ksu.edu!rutgers!sun-barr!male!pitstop!sundc!seismo!uunet!dalsqnt!usl!pcb From: pcb@usl.usl.edu (Peter C. Bahrs) Newsgroups: comp.lang.c++ Subject: Pointers to Methods Question Message-ID: <797@usl.usl.edu> Date: 30 Apr 89 20:15:16 GMT Organization: CACS, Lafayette, LA, USA Lines: 53 Very recently someone (??) put a question about virtual pointers et.al. on the net. I typed a variation of this in and am not sure why I receive the results below? Any comments? Script started on Sun Apr 30 14:10:33 198 -pcb--> cat b.c #include class What { public: What (void) { cout << form("Construct What\n"); } void virtual print(); }; void What::print() { cout << form ("I am What's print routine\n"); } class Where : public What { public: Where (void) { cout << form("Construct Where\n"); } void print(void) { cout << form ("Where's print routine\n"); } }; main () { typedef void What::WhatMember(); typedef void Where::WhereMember(); What* x = new What; Where* y = new Where; WhatMember* fp1; WhereMember* fp2; fp1 = &Where::print; (x->*fp1)(); fp2 = &Where::print; (y->*fp2)(); } -pcb--> CC b.c -o b CC b.c: cc -o b b..c /usr/local/lib/libC.a -pcb--> b Construct What Construct What Construct Where I am What's print routine Where's print routine -pcb--> ^D script done on Sun Apr 30 14:11:07 198