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

  • SEARCH
  • Home
  • 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 7710909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:14:29+00:00 2026-06-01T01:14:29+00:00

in this short code: class X { private: class Y { public: typedef void

  • 0

in this short code:

class X
{
private:
    class Y
    {

    public:
        typedef void (X::* ptr_to_mem)();
        Y(X* parent,ptr_to_mem ptr):parent_(parent),ptr_(ptr)
        {}
        void run()
        {
            parent_->*ptr_();//at this line I'm getting an error
        }
    private:
        X* parent_;
        ptr_to_mem ptr_;
    };

public:
    void some_fnc()
    {
        cout << "some_fnc";
    }

    void another()
    {
        Y y_(this,&X::some_fnc);
        y_.run();
    }

};

error:

error: must use '.*' or '->*' to call pointer-to-member function in '((X::Y*)this)->X::Y::ptr_ (...)', e.g. '(... ->* ((X::Y*)this)->X::Y::ptr_) (...)'
  • 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-06-01T01:14:30+00:00Added an answer on June 1, 2026 at 1:14 am

    Add an extra pair of parens:

    (parent_->*ptr_)();
    

    See C++FAQ lite 33.6.

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

Sidebar

Related Questions

I have this code (two classes) class url { private $profile_id; private $short; public
My short code : class A { private B b; public void b(){}; }
this is my activity code public class HomeActivity extends Activity { private String html
In short: For this code: Encoding.ASCII.GetBytes(‚) I want the output to be 130, but
I'm folowing this tutorial to create php/jquery based chat application. In short, this code
The short version is that this doesn't appear to be a code problem (though
I have a class hierarchy similar to this one: public static class BaseConfiguration {
I know this sort of code is not best practice, but nevertheless in certain
I've see this sort of thing in Java code quite often... try { fileStream.close();
Code: ​var a = function() { this.message = hello; this.shout = function(){ alert(this.message); //

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.