I finally got into making member function pointers and it took me a while because of the small difference with the other pointers, but there's one thing I don't understand: it's the way the function's address are allocated, they seem to follow no logic at all... Let's take for example a class with 2 ints in it:
So the address to the class could be 1000, (example) so then the first int should be at address 1000 too, and the other one, "b", should be at 1004... But as for functions, they are placed in memory to places that doesn't even follow the class's begeninng address, and there is no way to find a pattern to that....Code:class X { int a, b; };
But was is really going on with all this? Can we decide to place the member functions at address that follows the class?
I know for instance that when you copy (entirely) a variable of any class, it just copies all bytes from "&X" to "&X + sizeof(X)" (if X was a var. of a class) So for this if the functions were "inside" the class it would copy unnecessary infos. But then where does the functions address comes from, and why don't they are in a pattern of fixed step of memory???