I happen to came across an case, where I have below class ( note that float is commented ) and when calculated the size. Output : 16. (can be verified on - http://th.cpp.sh/)
when float is added to this class, but to my surprise the size of class remain unchanged and still o/p : 16.
Shouldn't it output a value : 20 ?? (considering integer and vptr pointer are 8 bytes and float 4 bytes)
// Example program
#include <iostream>
#include <string>
class A
{
public:
int a;
// float b;
virtual void f();
};
int main()
{
std::cout << sizeof(A);
return 0;
}