Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6338077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:22:24+00:00 2026-05-24T19:22:24+00:00

Possible Duplicate: Error with address of parenthesized member function In this recent question the

  • 0

Possible Duplicate:
Error with address of parenthesized member function

In this recent question the OP ran into a strange provision of the C++ language that makes it illegal to take the address of a member function if that member function name is parenthesized. For example, this code is illegal:

struct X {
    void foo();
};

int main() {
    void (X::* ptr)();
    ptr = &(X::foo);   // Illegal; must be &X::foo
}

I looked this up and found that it’s due to §5.3.1/3 of the C++ ISO spec, which reads

A pointer to member is only formed when an explicit & is used and its operand is a qualified-id not enclosed in parentheses […]

Does anyone have any idea why the spec has this rule? It’s specific to pointers-to-member, so I would suspect that there is some grammatical ambiguity that this resolves, but I honestly haven’t the faintest idea what it might be.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:22:25+00:00Added an answer on May 24, 2026 at 7:22 pm

    This is just a personal opinion.
    If &(qualified-id) is allowed as &(unary-expression),
    qualified-id has to be an expression, and an expression is expected to have a type
    (even if it is incomplete).
    However, C++ didn’t have a type which denotes a member, had only
    a pointer to member.
    For example, the following code cannot be compiled.

    struct A { int i; };
    
    template< class T > void f( T* );
    
    int main() {
      (void) typeid( A::i );
      f( &A::i );
    }
    

    In order to make &(qualified-id) be valid, the compiler has to hold
    a member type internally.
    However, if we abandon &(qualified-id) notation, the compiler doesn’t need
    to handle member type.
    As member type was always handled in the form of a pointer to it,
    I guess the standard gave priority to simplify the compiler’s type
    system a little.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How to get the address of an overloaded member function? I have
Possible Duplicate: Error: No previous prototype for function. Why am I getting this error?
Possible Duplicate: malloc.c:3074 error? I am getting this strange error on execution of my
Possible Duplicate: PHP ToString() equivalent I get this error: Catchable fatal error: Object of
Possible Duplicate: raise error within MySql function In MsSQL I can raise a custom
Possible Duplicate: Error: could not find function … in R I find various references
Possible Duplicate: 500 - An error has occurred! DB function reports no errors when
Possible Duplicate: Error handling in C code Let's say you have a function: int
Possible Duplicate: jQuery ajax error function I am trying to replace a global ajax
Possible Duplicate: Weird “406 not acceptable” error following code generate a 406 Not Acceptable

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.