I was learning about virtual function that whenever a class has virtual function as member function in it then compiler creates a *_vptr pointer in that class.
#include<bits/stdc++.h>
using namespace std;
class A
{
int a;
int b;
int c;
public:
A()
{
}
virtual void f1()
{
}
virtual void f2()
{
}
};
int main()
{
A obj;
cout<<sizeof(obj);
return 0;
}
So according to this concept size of my class A should be 20 bytes.
Assuming size of int as 4 bytes and size of pointer as 8 bytes.
But in compiler it is showing 24 bytes?
Why this is happening?