Regression with pmfs??

Klaus-Georg Adams
Tue Oct 27 01:30:00 GMT 1998

You wrote:

> 	  typedef const double (B::*Func)() const;
> 	  const Func D1 = &A::A1;
> 	  const Func D2 = &A::A2;
> Note: The two line defining D1 and D2 do not compile if I remove the 
> class spec "A::". Why do I have to specify this ??

That's the way a pointer to member is defined in ANSI C++:

[expr.unary.op], clause 3:
A pointer to member is only formed when an explicit & is used and its
operand is a qualified-id not enclosed in parentheses. [Note: that
is, the expression `&(qualified-id)', where the qualified-id is
enclosed in parentheses, does not form an expression of type "pointer
to member." Neither does `qualified-id', because there is no implicit
conversion from a qaulified-id for a nonstatic member function to the
type "pointer to member function" as there is from an lvalue of
function type to the type "pointer to function" (4.3). Nor is
`&unqualified-id' a pointer to member, even within the scope of the
unqualified-id's class. ]

A::A1 is a qualified id, A1 is a unqualified id.

-- kga
Klaus-Georg Adams        Email:
Institut f. Anorg. Chemie, Lehrstuhl II            Tel: 49(0)721 608 3485
Universität Karlsruhe, D-76128 Karlsruhe

More information about the Gcc-bugs mailing list