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 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

Related Questions

I am not sure if this question is already answered. But here it goes:
not sure its a stack overflow question I have a Mac and am hosting
I'm not sure exactly how to describe this question, but here goes. I've got
I'm sure this question has already been asked in one form or another, but
I'm not sure this question is appropriate here but I hope I could get
I'm not sure if this question fits properly, but I'm wondering in tile-based games,
I'm not sure whether this question belongs on StackOverflow or SuperUser, but here goes
I'm not sure if this question has been asked before but are there any
Bit of a javascript newbie so not sure if this question is easy or
Alright, I'm not sure if this question has been asked before so if it

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.