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 6967477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:19:36+00:00 2026-05-27T16:19:36+00:00

When I need a pointer to member of class, I do as following struct

  • 0

When I need a pointer to member of class, I do as following

struct MyStruct
{
    int foo();
};

int (MyStruct::*p)() = &MyStruct::foo;

My question is why do I need to use & operator to take the address which may be ignored if it were a static function. Also, I’ve heard pointer to members aren’t really a pointer, Can someone clarify that?

  • 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-27T16:19:37+00:00Added an answer on May 27, 2026 at 4:19 pm

    If it’s a static function, it works just as a regular non-member function pointer: the function name itself can be implicitly converted to a function pointer.

    If it’s a non-static member function, it’s no longer the same thing as a non-member function:

    1. It has a hidden this parameter;
    2. In a multiple inheritance scenario, converting a pointer to one of the base classes may produce a pointer to a different address. This means that if the member function is inherited, the this pointer may need to be adjusted before the call. This already makes it impossible to use a pointer to store a pointer-to-member-function.

    Raymond Chen wrote an interesting article about this with more details and examples.

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

Sidebar

Related Questions

I'm familiar with C++ constructors & initializers: class Foo { int x; public: Foo(int
As one of the class template parameters I need to use a pointer to
i need a Function Pointer from a base class. Here is the code: class
I've got a conversion operator that returns a const pointer, and I need to
I have class foo that contains a std::auto_ptr member that I would like to
I have class with member functions: typedef std::function<bool (const std::string &)> InsertFunction; bool insertSourceFile(
I need to implement the overloaded the assignment operator in a class so the
I need an array to hold member-function-pointers of different classes. How can I define
Edit: The reason queue is 2d is because I need a pointer of Command
This concept seems to trouble me. Why does an NSError object need its pointer

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.