Re: Member function pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In section 5.3.1 paragraph 1 and paragraph 3 of the C++ spec, I
believe you'll find the reason for that error:

Paragraph 1:

The unary * operator performs indirection: the expression to which it
is applied shall be a pointer to an object type, or a pointer to a
function type and the result is an lvalue referring to the object or
function to which the expression points. If the type of the expression
is "pointer to T," the type of the result is "T." [Note: a pointer to
an incomplete type (other than cv void ) can be dereferenced. The
lvalue thus obtained can be used in limited ways (to initialize a
reference, for example); this lvalue must not be converted to an
rvalue, see 4.1. ]

Paragraph 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 qualified-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. ]

corey

On 5/24/05, Eljay Love-Jensen <eljay@xxxxxxxxx> wrote:
> Hi Rune,
> 
> func is a data member of the testfnptr object.
> 
> Change this...
> if (0 != (this->*func))
> ...to this...
> if (0 != func)
> 
> HTH,
> --Eljay
> 
>


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux