Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!munnari.oz.au!manuel!ccadfa!Christopher-Vance@adfa.oz.au From: Christopher-Vance@adfa.oz.au (Christopher JS Vance) Newsgroups: comp.lang.c++ Subject: pointer to member function Message-ID: <2243@ccadfa.adfa.oz.au> Date: 11 Feb 91 05:01:53 GMT Sender: cjsv@ccadfa.adfa.oz.au Organization: Computer Science, Univ. of NSW, ADFA Canberra, Australia Lines: 46 I am using cfront 1.2.1 (dated 2/16/87), and am having trouble getting pointers to member functions to work. | #include | | struct a; | typedef void (a::*h)(); | | struct a { | void c(); | void d(); | void (a::*e)(); | h f; | a() { e = h(&a::c); f = e; } | }; | | void a::c() { cerr << "this is a::c\n"; e = &a::d; } | | void a::d() { cerr << "this is a::d\n"; } | | int main() { | a anA; | (anA.e)(); // line A line A: error: object missing in call through pointer to member function | (anA.*f)(); // line B line B: error: f is undefined line B: error: pointer to member function expected in .* expression: any | } And then I get a core dump from cfront, presumably before it's finished that last error message. From reading Stroustrup's `The C++ Programming Language', it seems to me that line A could reasonable be expected to have an error message, although perhaps not the one I see. It also seems that there should be no error in line B. Have I done something stupid, or should I wait 18 months for AT&T to get around to delivering the sources of cfront 2.x? (It took *that long* to get them to send us the version we have, so I'm not holding my breath.) -- Christopher