I don't undertand the output shown below.
I know that whenever a virtual function is present it creates a vptr
but still the size printed is more than I would expect:
#include<iostream>
using namespace std;
class Base
{
int x;
int y;
int z;
public:
virtual void fun(){}
virtual void fun2(){}
};
class Derived:public Base
{
public:
void fun() override {}
};
int main(int argc, char const *argv[])
{
cout<<sizeof(Base)<<endl;
cout<<sizeof(Derived)<<endl;
cout<<sizeof(int)<<endl;
}
24
24
4
[Finished in 0.3s]