As explained in one of the solutions of this question (Size of virtual pointer-C++) that you can calculate virtual pointer size in following manner :
struct virtual_base {
int data;
virtual_base() {}
virtual ~virtual_base() {}
};
struct non_virtual_base {
int data;
non_virtual_base() {}
~non_virtual_base() {}
};
int main() {
std::cout << sizeof( virtual_base ) - sizeof( non_virtual_base ) << '\n';
return 0;
}
But when i try this on cpp.sh http://cpp.sh/7o5av, without data (member variable) i get the size as 7 and with data size is coming out to be 12, so i failed to understand this behavior and any insights will be helpful and i know that size of empty class is 1 and in second with data member i expect this should come as 11 and not 7