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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T15:52:48+00:00 2026-05-10T15:52:48+00:00

Say I have: void Render(void(*Call)()) { D3dDevice->BeginScene(); Call(); D3dDevice->EndScene(); D3dDevice->Present(0,0,0,0); } This is fine

  • 0

Say I have:

void Render(void(*Call)()) {     D3dDevice->BeginScene();     Call();     D3dDevice->EndScene();     D3dDevice->Present(0,0,0,0); } 

This is fine as long as the function I want to use to render is a function or a static member function:

Render(MainMenuRender); Render(MainMenu::Render); 

However, I really want to be able to use a class method as well since in most cases the rendering function will want to access member variables, and Id rather not make the class instance global, e.g.

Render(MainMenu->Render); 

However I really have no idea how to do this, and still allow functions and static member functions to be used.

  • 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. 2026-05-10T15:52:49+00:00Added an answer on May 10, 2026 at 3:52 pm

    There are a lot of ways to skin this cat, including templates. My favorite is Boost.function as I’ve found it to be the most flexible in the long run. Also read up on Boost.bind for binding to member functions as well as many other tricks.

    It would look like this:

    #include <boost/bind.hpp> #include <boost/function.hpp>  void Render(boost::function0<void> Call) {     // as before... }  Render(boost::bind(&MainMenu::Render, myMainMenuInstance)); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have two functions that expect ...rest parameters private function a(...myParams):void { trace(myParams.length);
Lets say I have this code: public void MyMethod(string Data, List<string> InputData) { //I
Say, I have a code snippet like this: public static void main(String[] args) {
this is some kind of long post, so I have to say thanks for
Let's say I have two functions: void foo() { // A big function }
This has been bothering me for a long time now: Lets say i have
Say I have a function named: void AFun() { // body } Is it
Lets say I have the function void do_work (foo?); The ? represents a 0
Say I have a test like: void TestSomething(int someParam) { // Test code }
Say I have superclass which listens to a notification: @implementation SuperClass - (void)viewWillAppear:(BOOL)animated {

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.