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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:59:42+00:00 2026-06-09T21:59:42+00:00

Isn’t a pointer just an address? Or I’m missing something? I tested with several

  • 0

Isn’t a pointer just an address? Or I’m missing something?

I tested with several types of pointers:

  • pointers to any variables is the same (8B on my platform)
  • pointers to functions are the same size, as pointers to variables (8B again)
  • pointers to functions with different parameters – still the same (8B)

BUT pointers to member functions are bigger – 16B on my platform.

Three things:

  1. Why are pointers to member functions bigger? What more information do they need?
  2. As far as I know, the standard says nothing about the size of a pointer, except that void* must be able to “contain” any pointer type. In other words, any pointer must be able to be casted to void*, right? If so, then why sizeof( void* ) is 8, while sizeof a pointer to member function is 16?
  3. Are there any other examples for pointers, that are with different size (I mean, for standard platforms, not some rare and special ones)?
  • 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-09T21:59:44+00:00Added an answer on June 9, 2026 at 9:59 pm

    In the most normal situation, you can pretty much think of

    struct A {
        int i;
        int foo() { return i; }
    };
    
    A a;
    a.foo();
    

    as

    struct A {
        int i;
    };
    int A_foo( A* this ) { return this->i; };
    
    A a;
    A_foo(&a);
    

    (Starting to look like C, right?) So you would think the pointer &A::foo would just be the same as a normal function pointer. But there are a couple of complications: Multiple inheritance, and virtual functions.

    So imagine we have:

    struct A {int a;};
    struct B {int b;};
    struct C : A, B {int c;};
    

    It might be laid out like this:

    Multiple inheritance

    As you can see, if you want to point to the object with an A* or a C*, you point to the start, but if you want to point to it with a B* you have to point somewhere in the middle.

    So if C inherits some member function from B and you want to point to it then call the function on a C*, it needs to know to shuffle the this pointer. That information needs to be stored somewhere. So it gets lumped in with the function pointer.

    Now for every class that has virtual functions, the compiler creates a list of them called a virtual table. It then adds an extra pointer to this table to the class (vptr). So for this class structure:

    struct A
    {
        int a;
        virtual void foo(){};
    };
    struct B : A
    {
        int b;
        virtual void foo(){};
        virtual void bar(){};
    };
    

    The compiler might end up making it like this:
    enter image description here

    So a member function pointer to a virtual function actually needs to be an index into the virtual table.
    So a member function pointer actually needs 1) possibly a function pointer, 2) possibly an adjustment of the this pointer, and 3) possibly a vtable index. To be consistent, every member function pointer needs to be capable of all of these. So that’s 8 bytes for the pointer, 4 bytes for the adjustment, 4 bytes for the index, for 16 bytes total.

    I believe this is something that actually varies a lot between compilers, and there are a lot of possible optimizations. Probably none actually implements it the way I’ve described.

    For a lot of detail, see this (scroll to "Implementations of Member Function Pointers").

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

Sidebar

Related Questions

Isn't a pointer just a reference when you don't de-reference it? #include stdafx.h #define
Isn't having String enough? Just as an example, why can String class lets you
Isn't there another way of using global variables in a Java stlye manner in
Why isn't my Scrollview automatic scrolling? I don't get it.. it just doesn't move...
% isn't defined. modulo only works on integers. I want something equivalent to Javascript's
Isn't SQL Server sessioning for an ASP.NET MVC application fundamentally the same as ASP.NET?
Isn't toList a method that converts something into a List? If yes so why
Isn't there any built in class in PHP that has HashTable in PHP? If
Isn't there any way to find the class-type of a generic? if (T instanceof
Isn't Nothing a subtype of all types? scala> val array = new Array(5) array:

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.