Topic: Typedefs of member functions
Author: maxtal@physics.su.OZ.AU (John Max Skaller)
Date: Sat, 7 May 1994 15:47:55 GMT Raw View
In article <JASON.94May6165247@deneb.cygnus.com> jason@cygnus.com (Jason Merrill) writes:
>Is this code well-formed?
Who can tell? There is no type 'member function'.
There are only pointers to them. But that doesnt automatically rule
out a typedef, since a typedef is just a syntax macro -- its supposed
to be an alias for a "type" but "type" isnt so well defined.
>If not, how do you define a typedef for declaring methods?
Maybe you cant, maybe you can. Its been discussed.
I dont recall a resolution (which doesnt mean there wasnt one :-)
>
>struct A {
> typedef void (A::fn)();
>};
>
>struct B: public A {
> fn f;
>};
>
>void B::f () { }
--
JOHN (MAX) SKALLER, INTERNET:maxtal@suphys.physics.su.oz.au
Maxtal Pty Ltd, CSERVE:10236.1703
6 MacKay St ASHFIELD, Mem: SA IT/9/22,SC22/WG21
NSW 2131, AUSTRALIA
Author: jason@cygnus.com (Jason Merrill)
Date: Fri, 6 May 1994 23:52:46 GMT Raw View
Is this code well-formed? If so, why? Does the method basetype get
coerced silently to the derived type? Please provide a citation from the
latest WP. If not, how do you define a typedef for declaring methods?
struct A {
typedef void (A::fn)();
};
struct B: public A {
fn f;
};
void B::f () { }
Jason
Author: rfg@netcom.com (Ronald F. Guilmette)
Date: Sat, 7 May 1994 09:00:06 GMT Raw View
In article <JASON.94May6165247@deneb.cygnus.com> jason@cygnus.com (Jason Merrill) writes:
>Is this code well-formed? If so, why? Does the method basetype get
>coerced silently to the derived type? Please provide a citation from the
>latest WP. If not, how do you define a typedef for declaring methods?
>
>struct A {
> typedef void (A::fn)();
>};
>
>struct B: public A {
> fn f;
>};
>
>void B::f () { }
Jason,
I really wish that I could cite chapter and verse on this one, but all I
can tell you is what I believe.
I believe that it is not valid to declared *any* member using a class-
qualified name. Thus, the typedef in your code above is invalid.
This is not very different from:
struct B;
struct A {
int B::member;
};
which, I believe, is also invalid.
--
-- Ron Guilmette, Sunnyvale, CA ---------- RG Consulting -------------------
---- domain addr: rfg@netcom.com ----------- Purveyors of Compiler Test ----
---- uucp addr: ...!uunet!netcom!rfg ------- Suites and Bullet-Proof Shoes -