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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:20:51+00:00 2026-05-11T10:20:51+00:00

I am not sure if the question is already addressed. I was checking the

  • 0

I am not sure if the question is already addressed. I was checking the one of the Stack overflow function and got this doubt.

Lets check the code first:

#include <string> #include <map> #include <iostream.h>  class MyClass { public:      virtual  int Func()     {         return 0;     }      int Func2()     {         return 0;     }  };  class MyClass2 :  public MyClass { public:      int Func( )     {         return 1;     }      int Func2()     {         return 1;     }  };  class Processor {  private:       typedef int (MyClass::*MemFuncGetter)();       static std::map<std::string, MemFuncGetter> descrToFuncMap;   public:         static void Initialize();         void Process(MyClass* m, const std::string&);  };  std::map<std::string, Processor::MemFuncGetter> Processor::descrToFuncMap; void Processor::Initialize() {       descrToFuncMap['Func']=&MyClass::Func;      descrToFuncMap['Func2']=&MyClass::Func2; };  void Processor::Process(MyClass* ms, const std::string& key) {     std::map<std::string, MemFuncGetter>::iterator found = descrToFuncMap.find(key);      if(found != descrToFuncMap.end())      {         MemFuncGetter memFunc = found->second;         int dResult = (ms->*memFunc)();         cout << 'Result is : '<< dResult <<endl;       }  }   int main(int argc, char* argv[]) {     Processor::Initialize();     Processor p;      MyClass *pMC2 = new MyClass2;     p.Process(pMC2, 'Func');     p.Process(pMC2, 'Func2');      delete pMC2;     pMC2 = NULL;      return 0; } 

In this example, the result is as expected:

Result is : 1 Result is : 0 

But when I debugged using VC 6 debugger and observed the value of memFunc in Processor::Process and found following values:

In p.Process(pMC2, ‘Func’); call

memFunc 0x004011bd [thunk]:`vcall'{0,{flat}}'  

In p.Process(pMC2, ‘Func2’); call

memFunc 0x0040118b MyClass::Func2(void) 

I didn’t understand thunk and flat in ‘[thunk]:`vcall'{0,{flat}}’ ? Can anyone help me to understand the internals here ?

  • 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-11T10:20:52+00:00Added an answer on May 11, 2026 at 10:20 am

    There is a pretty thorough explanation of what thunk means over on WikiPedia

    http://en.wikipedia.org/wiki/Thunk

    The gist of is thunk is the mechanism by which the C++ virtual table is accessed at runtime. It is setup to call the appropriate virtual function for the runtime type of the object.

    As to what the vcall{0,{flat}} means I am not 100% sure. My guess is that it’s reporting the values by which the thunk is accessing the method.

    • 0: Offset in the vtable
    • {flat}: inheritance hierarchy is flat not multiple
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 81k
  • Answers 81k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There are a few accepted patterns here, and you can… May 11, 2026 at 4:34 pm
  • Editorial Team
    Editorial Team added an answer Use the selectedIndex property on the UITabBarController. More information can… May 11, 2026 at 4:34 pm
  • Editorial Team
    Editorial Team added an answer It's simply not implemented yet. Over time we will come… May 11, 2026 at 4:34 pm

Related Questions

I am having an issue on Sorting a ListBox with a dropdown. The dropdown
While working with ASP.NET MVC, I have noticed that exception messages issued by the
I'm writing a stored procedure that needs to have a lot of conditioning in
I am getting the error OperationalError: FATAL: sorry, too many clients already when using

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.