I just to understand the logic behind this code. When member function is not part of the object then how does the compiler invokes the function. Somehow the compiler needs to know the address of the function to invoke. Where it gets the address of the right function.I know this is silly question but curious to understand the underlying truth behind this
#include <iostream>
using namespace std;
class Base {
public:
Base() {
cout << "Base class constructor\n";
}
void Fun()
{
cout << sizeof(this) << endl;
cout << "This is member function" ;
}
void Fun1()
{
cout << "This is second member fun" << endl;
}
int Val;
};
int main(int argc, char* argv[])
{
Base Obj;
cout << sizeof(Obj) << endl;
Obj.Fun();
return 0;
}