Newsgroups: comp.lang.c++ Path: utzoo!utgpu!jarvis.csri.toronto.edu!dgp.toronto.edu!flaps From: flaps@dgp.toronto.edu (Alan J Rosenthal) Subject: Re: Pointers to Inline Members Message-ID: <8808271631.AA21050@explorer.dgp.toronto.edu> Organization: University of Toronto References: <3690002@wdl1.UUCP> Date: Sat, 27 Aug 88 11:11:10 EDT In article <3690002@wdl1.UUCP> rme@wdl1.UUCP (Richard M Emberson) writes: >Question: What about pointers to inline function members? > >Is this disallowed or should C++ keep "real" functions of >all the inline functions so that pointers to them can still be >taken. It seems that the current C++ compiler (at my site) handles this correctly, just like with pointers to consts, for example -- it creates an actual C-language object if and only if its address is taken. While testing this, I found the compiler unwilling to take a local declaration of the form: int (*f)(int); , and when looking through Stroustrup to try to find what I did wrong, this seemed to be right but I couldn't find any example of it! He seems always to declare function-pointers outside of functions, i.e. as external variables. Furthermore, the compiler DOES accept: auto int (*f)(int); as a local declaration. Any clues? I'm using cfront 1.2.1 2/16/87, according to the usage message. The actual program used is the following, which fails to compile when the word ``auto'' is removed. As shown it correctly outputs "3 4". #include class classname { public: int f(int x) { return x; } }; int main() { class classname xxx; auto int (classname::*g)(int); cout << xxx.f(3) << " "; g = &(classname::f); cout << (xxx.*g)(4) << "\n"; return 0; } ajr -- owotd (rot13): fabgentf