Christopher-Vance@adfa.oz.au (Christopher JS Vance) (02/11/91)
I am using cfront 1.2.1 (dated 2/16/87), and am having trouble getting pointers to member functions to work. | #include <stream.h> | | 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
steve@taumet.com (Stephen Clamage) (02/12/91)
Christopher-Vance@adfa.oz.au (Christopher JS Vance) writes: >I am using cfront 1.2.1 (dated 2/16/87), and am having trouble getting >pointers to member functions to work. >From reading Stroustrup's `The C++ Programming Language'... If memory serves, pointers to member functions were not part of the language prior to cfront 2.0, and are not in Stroustrup's original book. You need a recent compiler and reference book. There have been numerous significant language changes since 1987, including changed syntax and semantics, and staying with an obsolete version of C++ will only lead to further confusion. -- Steve Clamage, TauMetric Corp, steve@taumet.com