I was revising the C++ concepts, but I am stuck with a very simple code
#include <iostream>
using namespace std;
class foo {
public:
//int i;
void virtual foobar()
{
cout << "foobar\n";
}
};
int main()
{
foo f;
cout << sizeof(f) << endl;
//cout << sizeof(f.i) << endl;
return 1;
}
The output of the above code is 8 But when I removed comments from the code Output is 16 and 4
I did not understand when the class have no member variable present then VPTR size is 8 but after adding a variable size becomes 12.