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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:48:02+00:00 2026-06-17T17:48:02+00:00

I am writing a wrapper for a multithreaded scheme. It should operate similar to

  • 0

I am writing a wrapper for a multithreaded scheme. It should operate similar to a timer.

I have a particular class (clock) that implements a function called tick which should be passed to constructor. How do I describe a C++ style function (myClass::myfunction, as opposed to the C convention) as the parameter to a method or constructor?

Would anybody be kind enough to show me the declaration for this kind of constructor?

clock myInstance(otherClass::aMethod)
myInstance.tick(); // Should call otherClass::aMethod
myInstance.tick();

Does C++11 and Bind help?

  • 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-17T17:48:04+00:00Added an answer on June 17, 2026 at 5:48 pm

    You can either call a static member function of a class or a non-static member function of an object. A non-static member function needs to have the context of an object (this pointer).

    Here’s a simplified example of how you can use functors and bind to call a member function.

    #include <functional>
    
    class clock
    {
    public:
       clock(const std::function<void()>& tocall) : m_tocall(tocall) {}
       void tick() {m_tocall();}
    
    private:
       std::function<void()> m_tocall;
    };
    
    class otherclass
    {
    public:
       void aMethod() {}
    };
    
    int main(int argc, char *argv[])
    {
       otherclass A;
       clock c( std::bind(&otherclass::aMethod, &A) );
    
       c.tick(); // Will end up calling aMethod() of object A
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a wrapper around a class library that I have no control over.
I'm writing a wrapper to a function that takes varargin as its inputs. I
I'm writing a wrapper class around the V8 engine so that eventually I'll be
I'm writing a wrapper application that will be used to provide an abstraction layer
I'm writing a wrapper program that loads Winamp input plugins. I've got it working
I am writing a wrapper library for log4net. This library should be able to
I'm writing a little wrapper for an application that uses files as arguments. The
I am writing a wrapper class to call _CrtDumpMemoryLeaks() in WPF application. I am
I'm writing a wrapper class around a TcpClient which raises an event when data
I'm currently writing a wrapper library for windows mobile in C/C++. I have to

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.