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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:26:10+00:00 2026-05-27T13:26:10+00:00

I am tracking three color points – red, green and blue. I have currentFrames

  • 0

I am tracking three color points – red, green and blue. I have currentFrames class, which holds a couple of frames – frame from camera and some auxiliary ones – and some methods to manipulate/extract some info from frames. Let’s say I am able to locate centroid of each point, and then I want to call specific function based on position of this centroid. Whole frame is divided into grid and each segment of the grid will have function assigned to it – that function will be called when point is detected in this particular segment.

My idea is to create multi-dimensional array of pointers to member functions:

#define CALL_MEMBER_FN(object,ptrToMember)  ((object).*(ptrToMember))
MyFuncPointerType functions[NUMBER_OF_POINTS][NUMBER_OF_SEGMENTS];

and then assign addresses of functions to this like:

functions[0][0] = &currentFrames::something;

When, for example, first point will be located in second segment of the grid, then I will call proper function (and this will be called from inside currentFrames class – that’s why I am passing *this as a object to CALL_MEMBER_FN:

CALL_MEMBER_FN(*this, functions[0][1])();

I have started with not so complicated example – I want to call different functions for each point, but the same for each segment (“in scope of point”):

class currentFrames
{
    public:
    void someMethod();

    private:
    void calculateVelocity();
    void redPointDetected();
    void redPointGone();

    typedef void (currentFrames::*MyFuncPointerType)();
    MyFuncPointerType functions[];
}

Then, in constructor of currentFrames I do the following:

currentFrames::currentFrames()
{
    this->functions[0] = &currentFrames::calculateVelocity;
    this->functions[1] = &currentFrames::redPointDetected;
}

Then, in someMethod in currentFrames class I try to call member function:

void currentFrames::someMethod()
{
    CALL_MEMBER_FN(*this, this->functions[0])();
}

But this gives me segfault. I tried to define CALL_MEMBER_FN as ((ptrToObject)->*(ptrToMember)), but this also gives segfault.

How this should be done? Is there a better way to achive what I want?

  • 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-27T13:26:10+00:00Added an answer on May 27, 2026 at 1:26 pm
        MyFuncPointerType functions[];
    

    You forgot to give the length of array. This will make it equvilent to MyFuncPointerType *functions. The pointer is initialized to some garbage address (probably 0) and causes segment when accessing this->functions[0] in the constructor. This has nothing to do with CALL_MEMBER_FN.

    Change this line to

        MyFuncPointerType functions[2];
    

    and it should work. (Demo: http://ideone.com/q4D3e)

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

Sidebar

Related Questions

I'm writing an expense tracking program. At the moment I have three class Lineitem
I have a view in which I paint a dotted line when the user
Three questions for iPhone developers using Google Analytics within their apps for tracking use
I have a dialog box on which controls are added with resource editor. But
I have cron job - php script which is called one time in 5
I have an Excel file that I need to process three times in integration
I have the following task. Having three models Project, User and PurchaseOrder. I want
In SQL Server 2008, I have a table for tracking the status history of
I have a custom Qt widget which I used to display disassembly and I
Does anyone know of an application or system out there for tracking changes (files

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.